Ad

Postgresql Invalid Class For [:^punct]

- 1 answer

Having read the answer in the Remove all punctuation except apostrophes in R post, I tried to use

'[[:space:]]|[^\/[:^punct:]]'

in REGEXP_REPLACE function, but it gives me

[2201B] ERROR: invalid regular expression: invalid character class

How can I make it work?

Ad

Answer

The question you link to is tagged with , where stringr library uses ICU regex flavor that supports POSIX character classes in its own way, not necessarily POSIX compatible.

To match any whitespace or any punctuation but / you may use

[^/[:alnum:]]

It matches any char that is not alphanumeric (and that means it is either a whitespace or punctuation) and not a / char.

Ad
source: stackoverflow.com
Ad