Redshift: How to remove non-printable characters

2.8k Views Asked by At

I'm trying to remove non-printable characters from a string in Redshift and tried the TRANSLATE function but didn't return the results I'm looking for. Any advice?

2

There are 2 best solutions below

0
Chris KL On BEST ANSWER

Not quite right, this works:

regexp_replace(<col>, '[^[:alnum:][:blank:][:punct:]]', '')

It's a positive filter that will only allow ASCII, letters, numbers, spaces and punctuation.

0
Bill Weiner On

Here's a regexp I've used to get down to just the chars:

regexp_replace(<col>,'[^[:print:]]|[[:cntrl:]]|[[:blank:]]','')

Don't know if this is what you are looking for but a place to start.