Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EF1BD9FA017 for ; Sun, 28 Oct 2007 11:39:04 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 26701-09 for ; Sun, 28 Oct 2007 11:39:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 707B69FA015 for ; Sun, 28 Oct 2007 11:39:00 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Im9HF-00033I-70 for pgsql-sql@postgresql.org; Sun, 28 Oct 2007 14:38:09 +0000 Received: from ppp-82-135-90-137.dynamic.mnet-online.de ([82.135.90.137]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Oct 2007 14:38:09 +0000 Received: from spam_eater by ppp-82-135-90-137.dynamic.mnet-online.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Oct 2007 14:38:09 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Thomas Kellerer Subject: Re: Removing whitespace using regexp_replace Date: Sun, 28 Oct 2007 15:35:59 +0100 Lines: 16 Message-ID: References: <20071028114247.GA1327@KanotixBox> <20071028123254.GB17410@KanotixBox> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ppp-82-135-90-137.dynamic.mnet-online.de User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 In-Reply-To: <20071028123254.GB17410@KanotixBox> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/139 X-Sequence-Number: 29511 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