BUG #13310: Please update docs of regexp_replace()
BUG #13310: Please update docs of regexp_replace()
От:
guettli.postgres@thomas-guettler.de
Дата:
The following bug has been logged on the website:
Bug reference: 13310
Logged by: Thomas Güttler
Email address: guettli.postgres@thomas-guettler.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.
I would replace this example:
regexp_replace('Thomas', '.[mN]a.', 'M') ThM
With this one:
regexp_replace('fooooooobar', 'f(o*)bar', '\\1')
It can be any other example, but a "group insert" (\\1) would be very nice.
I talk about this:
Table 9-6. SQL String Functions and Operators
http://www.postgresql.org/docs/9.4/static/functions-string.htmlRe: BUG #13310: Please update docs of regexp_replace()
От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, May 18, 2015 at 2:11 AM,
wrote:
> The following bug has been logged on the website:
>
> Bug reference: 13310
> Logged by: Thomas G=C3=BCttler
> Email address: guettli.postgres@thomas-guettler.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
=E2=80=8BThis example assumes non-standard conforming strings. Standard co=
nforming
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.=E2=80=8B 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.