From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | guettli(dot)postgres(at)thomas-guettler(dot)de |
Cc: | "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #13310: Please update docs of regexp_replace() |
Date: | 2015-05-18 16:19:46 |
Message-ID: | CAKFQuwbuNxhr+ZET0AK_wCNpNhuTczfLEGnn3_6iQG9DG78t5g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Mon, May 18, 2015 at 2:11 AM, <guettli(dot)postgres(at)thomas-guettler(dot)de>
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 13310
> Logged by: Thomas Güttler
> Email address: guettli(dot)postgres(at)thomas-guettler(dot)de
> PostgreSQL version: 9.4.1
> Operating system: All
> Description:
>
> Please improve the example of regexp_replace():
>
> I am missing a "group insert" in the example.
>
> regexp_replace('fooooooobar', 'f(o*)bar', '\\1')
>
> http://www.postgresql.org/docs/9.4/static/functions-string.html
This example assumes non-standard conforming strings. Standard conforming
strings, which are what should be documented, would give two possibilities:
regexp_replace('','', E'\\1')
or
regexp_replace('','','\1')
My personal preference is that if you do not intend to have the string
literal actually escape something the second form, without the 'E'scape
specifier, should be used. However, it seems that many people take the
option requiring less thought and always prepend the E''. The
documentation elsewhere, I think, tends to take that approach as
well...though I haven't gone a tried to figure out statistics.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Julian Schauder | 2015-05-19 09:20:51 | Re: BUG #13307: Increasing space |
Previous Message | hubert depesz lubaczewski | 2015-05-18 13:36:48 | Re: GiST index for pgtrgm bloats a lot |