postgres - remove whitespace from field?
Posted
by n00b0101
on Stack Overflow
See other posts from Stack Overflow
or by n00b0101
Published on 2010-03-29T02:21:53Z
Indexed on
2010/03/29
2:23 UTC
Read the original article
Hit count: 907
I imported a bunch of data using pgloader, and am now seeing that there's a bunch of whitespace (both spaces and tabs) inside of the fields. Is there a way to quickly update the fields to remove it from the beginning, the end, and the middle? I know there's TRIM, but that won't work for me...
As an added problem... I only want to remove double spaces and replace it with a single space, but there might be 5 or 6 spaces in a row, and I'd prefer not to have to rerun a replace query until they're all ok?
I was looking at regex_replace, but, I'm not sure how to make certain that it removes it from the middle of a string as well...
© Stack Overflow or respective owner