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: 2007-10-28 14:35:59
Message-ID: fg26oe$dfg$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Paul Lambert 2007-10-28 23:11:00 Select into with dynamic criteria in a plpgsql function
Previous Message Andreas Kretschmer 2007-10-28 12:32:54 Re: Removing whitespace using regexp_replace