Re: regexp_replace grief

Поиск
Список
Период
Сортировка
От Armin Resch
Тема Re: regexp_replace grief
Дата
Msg-id CAGo0LBQauGMyD89HLHa=CM7yB9eEKMnx5hgq1QY0wZ7RfroixQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: regexp_replace grief  (Albe Laurenz <laurenz.albe@wien.gv.at>)
Ответы Re: regexp_replace grief  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-admin
Thx, Albe. I tested both proposals, and I gravitate now more towards the E'' nomenclature since it avoids something like this:

$pg_bs_char = ( $dbh->{pg_server_version} >= 90100 ) ? "\\" : "\\\\";

Hoping for a long half life of the E'' nomenclature ...

-ar 


On Fri, Apr 12, 2013 at 5:16 AM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
Armin Resch wrote:
> Not sure this is the right list to vent about this but here you go:
>
> I) select regexp_replace('BEFORE.AFTER','(.*)\..*','\1','g') "Substring"
> II) select regexp_replace('BEFORE.AFTER','(.*)\\..*','\\1','g') "Substring"
>
> Executing (II) against pg 8.4.4 or 9.0.4 yields 'BEFORE', but in order for 9.1.7 to yield the same one
> has to execute (I) .. bummer

To be immune against different settings of standard_conforming_strings,
use the extended string literal syntax:

select regexp_replace('BEFORE.AFTER',E'(.*)\\..*',E'\\1','g') "Substring";

That will work in all versions.

Yours,
Laurenz Albe

В списке pgsql-admin по дате отправления:

Предыдущее
От: Mike Broers
Дата:
Сообщение: Re: after 9.2.4 patch vacuumdb -avz not analyzing all tables
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: regexp_replace grief