We have data in Postgres something as below , there is possibility of having mutiple non-ascii chars in a string
| Name |
|---|
| Kate SolutionǸǸs |
| Etak Solutions |
We are trying to identify if there are any NON-ASCII char set from the string and remove all of them if there are any(if there no non-ascii then keep the string as is) and expecting output below output
| Name |
|---|
| Kate Solutions |
| Etak Solutions |
Tried using below SQL but its just removing only one non-ascii char irrespective of the position where it is present
select REGEX_REPLACE(name,'[^ -~]', '') as new_name from table
Appreciate any help!
>Solution :
From the Postgresql documentation:
If the g flag is given, or if N is specified and is zero, then all matches at or after the start position are replaced. (The g flag is ignored when N is specified.)
So either add a 4th parameter as zero, 0, or add a 6th parameter as ‘g’.