1 | initial version |
There are several ways to locate whitespace, special characters, excessive tabs, and carriage returns in text fields using PostgreSQL:
Example query:
SELECT * FROM mytable WHERE mytextfield ~ '\s'; -- finds records with any whitespace character in mytextfield SELECT * FROM mytable WHERE mytextfield ~ '[^[:alnum:][:space:]]'; -- finds records with any special character in mytextfield
Example query:
SELECT replace(mytextfield, E'\t', '') FROM mytable; -- removes all tabs from mytext_field
Example query:
SELECT regexpreplace(mytextfield, E'[^\w\s]', '', 'g') FROM mytable; -- removes all non-alphanumeric and non-whitespace characters from mytextfield