Re: [GENERAL] Regex match not back-referencing in function

2012-02-12 Thread Thom Brown
On 12 February 2012 18:49, Tom Lane wrote: > Thom Brown writes: >> What am I missing? > > I might be more confused than you, but I think you're supposing that > the result of ascii(E'\\1') has something to do with the match that > the surrounding regexp_replace function will find, later on when i

Re: [GENERAL] Regex match not back-referencing in function

2012-02-12 Thread David Johnston
On Feb 12, 2012, at 13:26, Thom Brown wrote: > Hi, > > Could someone explain the following behaviour? > > SELECT regexp_replace(E'Hello & goodbye ',E'([&])','&#' || > ascii(E'\\1') || E';\\1'); > > This returns: > > regexp_replace > > Hello \& goodbye > (1 row) >

Re: [GENERAL] Regex match not back-referencing in function

2012-02-12 Thread Tom Lane
Thom Brown writes: > What am I missing? I might be more confused than you, but I think you're supposing that the result of ascii(E'\\1') has something to do with the match that the surrounding regexp_replace function will find, later on when it gets executed. The actual arguments seen by regexp_

[GENERAL] Regex match not back-referencing in function

2012-02-12 Thread Thom Brown
Hi, Could someone explain the following behaviour? SELECT regexp_replace(E'Hello & goodbye ',E'([&])','&#' || ascii(E'\\1') || E';\\1'); This returns: regexp_replace Hello \& goodbye (1 row) So it matched: SELECT chr(92); chr - \ (1 row) But notice that w