Regular expressions: remove non alpha numerics, with an exception Regular expressions: remove non alpha numerics, with an exception postgresql postgresql

Regular expressions: remove non alpha numerics, with an exception


Then you need to use :

x = regexp_replace(somestring, '\W+', '', 'g')

\W is the same as [^a-zA-Z0-9_]


How about using '\W+' that replaces all non a-z and 0-9 leaving _ alone

So

x = regexp_replace(somestring, '\W+', '', 'g')