I am trying to replace multiple whitespaces from a column in Redshift(Postgres)
Query used :
Select replace(col_name,' ',' ') from table;
above query is not working for multiple whitespaces only.
I have tried replacing other characters in the same query, also for a single whitespace it’s working fine.
Can someone help me here?
2
Answers
This will replace all occurrences of multiple whitespaces with a single whitespace:
Based on the answer of @Quassnoi, this one works for me:
It uses the g flag, to search for all matches. And replace these matches.