Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id E0761B5DBCE for ; Sat, 17 Sep 2011 08:32:08 -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 37721-01 for ; Sat, 17 Sep 2011 11:32:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from mail43.e.nsc.no (mail43.e.nsc.no [193.213.115.43]) by mail.postgresql.org (Postfix) with ESMTP id 7FFA8B5DBC8 for ; Sat, 17 Sep 2011 08:32:00 -0300 (ADT) Received: from balapapa.localnet (107.100.202.84.customer.cdi.no [84.202.100.107]) (authenticated bits=0) by mail43.nsc.no (8.14.4/8.14.4) with ESMTP id p8HBVxY6008836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 17 Sep 2011 13:31:59 +0200 (MEST) From: Leif Biberg Kristensen To: pgsql-sql@postgresql.org Subject: Re: Passing function parameters to regexp_replace Date: Sat, 17 Sep 2011 13:31:58 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.39-gentoo-r3; KDE/4.6.5; x86_64; ; ) References: <201109171321.43309.leif@solumslekt.org> In-Reply-To: <201109171321.43309.leif@solumslekt.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109171331.58663.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: 201109/38 X-Sequence-Number: 35838 On Saturday 17. September 2011 13.21.43 Leif Biberg Kristensen wrote: > UPDATE sources SET source_text = regexp_replace(source_text, > E'n="(.*?)$1(.*?)"', E'n="\\1$2\\2"', 'g') where source_text like > '%n="%$2%">%'; Sorry, I pasted a literal replacement, and substituted the parameters by hand. The expression should of course be UPDATE sources SET source_text = regexp_replace(source_text, E'n="(.*?)$1(.*?)"', E'n="\\1$2\\2"', 'g') where source_text like '%n="%$1%">%' regards, Leif