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?
Asked
Active
Viewed 2,112 times
0
-
OP is correct in that TRANSLATE only does a specified character at a time - not very useful. – Chris KL Nov 17 '21 at 01:29
2 Answers
2
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.

Chris KL
- 4,882
- 3
- 27
- 35
-1
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.

Bill Weiner
- 8,835
- 2
- 7
- 18