Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id B8584B5DBD9 for ; Tue, 14 Jun 2011 16:48:11 -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 93144-10 for ; Tue, 14 Jun 2011 19:48:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 1D860B5DBD1 for ; Tue, 14 Jun 2011 16:48:04 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id BE88C348045; Tue, 14 Jun 2011 12:48:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JuK0cUNCZpGM; Tue, 14 Jun 2011 12:48:02 -0700 (PDT) Received: from perhan.alvh.no-ip.org (unknown [190.95.30.33]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id B810A348044; Tue, 14 Jun 2011 12:48:01 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 18ED26E381; Tue, 14 Jun 2011 15:47:59 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: pgsql-bugs Subject: Re: BUG #6057: regexp_replace & back references From: Alvaro Herrera To: Marc Mamin In-reply-to: <201106141631.p5EGVYnk056729@wwwmaster.postgresql.org> References: <201106141631.p5EGVYnk056729@wwwmaster.postgresql.org> Date: Tue, 14 Jun 2011 15:47:59 -0400 Message-Id: <1308080704-sup-5009@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit 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: 201106/109 X-Sequence-Number: 30488 Excerpts from Marc Mamin's message of mar jun 14 12:31:34 -0400 2011: > > The following bug has been logged online: > > Bug reference: 6057 > Logged by: Marc Mamin > Email address: marc@intershop.de > PostgreSQL version: 9.0.4 > Operating system: Windows > Description: regexp_replace & back references > Details: > > select regexp_replace ('a','(a)','\\1'||substring('\\1',1,1)||'\\1','g') > = a\1 > I'd expect a\1a as result. Note that the substring returns a single character which is a literal \. That \ escapes the \ in the final '\\1', which turns into the literal \ that you see in the result. The subsequent 1 is the leftover char from the final '\\1'. I think this is clearer if you set standard_conforming_strings to on. -- Álvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support