Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id EB367B5DBC8 for ; Wed, 3 Aug 2011 01:05:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 99378-07 for ; Wed, 3 Aug 2011 04:05:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 8366DB5DBC5 for ; Wed, 3 Aug 2011 01:05:39 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QoSi8-0006xS-Vl for pgsql-sql@postgresql.org; Wed, 03 Aug 2011 06:05:36 +0200 Received: from g224120012.adsl.alicedsl.de ([92.224.120.12]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Aug 2011 06:05:36 +0200 Received: from tim by g224120012.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 03 Aug 2011 06:05:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Re: Help with regexp-query Date: Wed, 03 Aug 2011 04:05:26 +0000 Organization: Lines: 29 Message-ID: References: <20110728112021.GA31921@sun.ac.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g224120012.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:08WWUtQHexIjDp1jxiUMxTBtBxw= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.701 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.801 X-Spam-Level: X-Archive-Number: 201108/10 X-Sequence-Number: 35678 Johann Spies wrote: > I am struggling a bit to do the following type of update in a table. > I want the content of a field updated like this: > Original: > '||||0894396e-16bf-4e63-aa52-97fe7031eec9||50a6b47c-f69c-414d-bcb6-14bbe403de5f|||' > After update: > '|0894396e-16bf-4e63-aa52-97fe7031eec9|50a6b47c-f69c-414d-bcb6-14bbe403de5f|' > in other words: change all multiple adjacent occurences of '|' to only 1. > I have tried the following query but it fails: > select id, regexp_replace(category, (E'\|{2,}'), E'\|') as category from > akb_articles limit 100 > This ends with 'ERROR: invalid regular expression: quantifier operand > invalid'. > I would apreciate some help with this one please. You need to double the backslashes (e. g. "E'\\|{2,}'"); otherwise the parser will "eat" the first backslash and pass just "|{2,}" as the second argument to regexp_replace(). Tim