Sample Header Ad - 728x90

(non-breaking space) is not considered whitespace by Postgres?

2 votes
2 answers
226 views
String-functions in Postgres do not recognize non-breaking-space as whitespace, neither when trimming nor when using regular expressions: ~~~pgsql select 'x' || test || 'x' , 'x' || trim(test) || 'x' , 'x' || regexp_replace(test, '\s+', '') || 'x' from (values (''), (' '), ('   y   '), ('s s s s') ) as foo(test) ~~~ (Not sure if the non-breaking ( ) survives in the above code, but the two last rows contain nbsp.) Onecompiler SQL demonstration Is it a Postgres-thing not to handle this, or is it a bug? I know of char(160) for nbsp, but would prefer en general-purpose way to strip all whitespace. Collation in use is en_US.utf8
Asked by Rune (123 rep)
Feb 27, 2025, 11:57 AM
Last activity: Mar 5, 2025, 02:00 PM