pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@commandprompt.com>
To: Marc Mamin <marc@intershop.de>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #6057: regexp_replace & back references
Date: Tue, 14 Jun 2011 15:47:59 -0400
Message-ID: <1308080704-sup-5009@alvh.no-ip.org> (raw)
In-Reply-To: <201106141631.p5EGVYnk056729@wwwmaster.postgresql.org>
References: <201106141631.p5EGVYnk056729@wwwmaster.postgresql.org>

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 <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



view thread (2+ messages)

Message-ID: <1308080704-sup-5009@alvh.no-ip.org>
Permalink:  ../1308080704-sup-5009@alvh.no-ip.org/
Also on:    postgresql.org/message-id/1308080704-sup-5009@alvh.no-ip.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@commandprompt.com, marc@intershop.de
  Subject: Re: BUG #6057: regexp_replace & back references
  In-Reply-To: <1308080704-sup-5009@alvh.no-ip.org>
  References: <201106141631.p5EGVYnk056729@wwwmaster.postgresql.org> <1308080704-sup-5009@alvh.no-ip.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox