Monday, March 23, 2015

Remove special characters from string using regexp functions

There is a need to remove special characters and non-printable characters that users have accidentally entered into CSV files. For every varchar2 field, I'd like to keep characters inside the range from chr(32) to chr(126), and remove everything else. 

This is the query to solve the problem, it use regexp functions

select regexp_replace('This is a test $%&^*&*'||chr(10)||'*"ú%bsfd.', '( *[[:punct:]])', '') from dual

I really like how regexp functions can do, for more information, check more from here:  http://psoug.org/reference/regexp.html

No comments:

Post a Comment