Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E2C43B5DC10 for ; Thu, 28 Jul 2011 08:20:34 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 03891-02 for ; Thu, 28 Jul 2011 11:20:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail2.sun.ac.za (mail2.sun.ac.za [146.232.64.14]) by mail.postgresql.org (Postfix) with ESMTP id 82707B5DC20 for ; Thu, 28 Jul 2011 08:20:28 -0300 (ADT) Received: from artikel.sun.ac.za ([146.232.82.145] helo=artikel) by mail2.sun.ac.za with esmtp (Exim 4.69) (envelope-from ) id 1QmOdZ-0001mz-FB for pgsql-sql@postgresql.org; Thu, 28 Jul 2011 13:20:21 +0200 Received: from js by artikel with local (Exim 4.76) (envelope-from ) id 1QmOdZ-0008N4-A6 for pgsql-sql@postgresql.org; Thu, 28 Jul 2011 13:20:21 +0200 Date: Thu, 28 Jul 2011 13:20:21 +0200 From: Johann Spies To: pgsql-sql@postgresql.org Subject: Help with regexp-query Message-ID: <20110728112021.GA31921@sun.ac.za> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.093 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.193 X-Spam-Level: X-Archive-Number: 201108/6 X-Sequence-Number: 35674 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. Regards Johann -- Johann Spies Telefoon: 021-808 4699 Databestuurder / Data manager Sentrum vir Navorsing oor Evaluasie, Wetenskap en Tegnologie Centre for Research on Evaluation, Science and Technology Universiteit Stellenbosch. "If any of you lack wisdom, let him ask of God, that giveth to all men liberally, and upbraideth not; and it shall be given him." James 1:5