Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C9D0C1337B9F for ; Fri, 24 Sep 2010 12:10:53 -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 36193-05 for ; Fri, 24 Sep 2010 15:10:46 +0000 (UTC) X-Greylist: delayed 00:31:36.020913 by SQLgrey-1.7.6 Received: from mail42.e.nsc.no (mail42.e.nsc.no [193.213.115.42]) by mail.postgresql.org (Postfix) with ESMTP id 31D7F1337B75 for ; Fri, 24 Sep 2010 12:10:45 -0300 (ADT) Received: from balapapa.localnet (207.100.202.84.customer.cdi.no [84.202.100.207]) (authenticated bits=0) by mail42.nsc.no (8.14.3/8.14.3) with ESMTP id o8OEd8kj025642 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 24 Sep 2010 16:39:08 +0200 (MEST) From: Leif Biberg Kristensen To: pgsql-sql@postgresql.org Subject: Re: find and replace the string within a column Date: Fri, 24 Sep 2010 16:39:07 +0200 User-Agent: KMail/1.13.5 (Linux/2.6.32-gentoo-r7; KDE/4.4.5; i686; ; ) References: <4C9C8CB4.3070205@postnewspapers.com.au> In-Reply-To: <4C9C8CB4.3070205@postnewspapers.com.au> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201009241639.07557.leif@solumslekt.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201009/102 X-Sequence-Number: 34633 On Friday 24. September 2010 13.34.12 Craig Ringer wrote: > On 24/09/2010 5:15 PM, Nicholas I wrote: > > > Example: > > table name person: > > > > name > > ------------------------------------ > > Samuel (S/o Sebastin ) > > ------------------------------------- > > > > remove the word within the brackets. > > the output should be , Samuel. > > Can't you just regexp_replace, matching \([^)]+\) (in other words "an > open parenthisis, then a sequence of one or more of any character other > than a close parenthesis, followed by a close parentheis) and replacing > with an empty string ? I'm doing a similar task, removing comments "hidden" within curly braces like this: str := REGEXP_REPLACE(str, '{.*?}', '', 'g'); No escaping needed at all. regards, Leif Biberg Kristensen