Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Removing whitespace using regexp_replace


  • From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
  • To: pgsql-sql(at)postgresql(dot)org
  • Subject: Re: Removing whitespace using regexp_replace
  • Date: Sun, 28 Oct 2007 15:35:59 +0100
  • Message-id: <fg26oe$dfg$1@ger.gmane.org> <text/plain>

Andreas Kretschmer wrote on 28.10.2007 13:32:
But it seems my problem was actually caused by something else:

SELECT regexp_replace(myfield, '\s*', '', 'g')
FROM mytable;

you should escape the \, change to ...'\\s*'...
Ah! Didn't think this was necessary, as \t or \n did not need to be escaped.

But without anchors this replaces all whitespaces, also within the text
and not only at the beginning/end (^ and $)
Yes of course, this was only for testing ;)

Thanks for your help!

Thomas




Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group