pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6057: regexp_replace & back references
2+ messages / 2 participants
[nested] [flat]

* BUG #6057: regexp_replace & back references
@ 2011-06-14 16:31 Marc Mamin <marc@intershop.de>
  2011-06-14 19:47 ` Re: BUG #6057: regexp_replace & back references Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Marc Mamin @ 2011-06-14 16:31 UTC (permalink / raw)
  To: pgsql-bugs


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.

More generally, I miss the avaibility to use back references as function
parameters. It is only possible with some operators (e.g. '\\1'||'\\1'),
probably depending on their lexical precedence. Any way to workaround this
limitation would be very helpful.

HTH,

Marc Mamin



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6057: regexp_replace & back references
  2011-06-14 16:31 BUG #6057: regexp_replace & back references Marc Mamin <marc@intershop.de>
@ 2011-06-14 19:47 ` Alvaro Herrera <alvherre@commandprompt.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Alvaro Herrera @ 2011-06-14 19:47 UTC (permalink / raw)
  To: Marc Mamin <marc@intershop.de>; +Cc: pgsql-bugs

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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-06-14 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-06-14 16:31 BUG #6057: regexp_replace & back references Marc Mamin <marc@intershop.de>
2011-06-14 19:47 ` Alvaro Herrera <alvherre@commandprompt.com>

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