Re: regexp_replace grief

From: Armin Resch <reschab(at)gmail(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: regexp_replace grief
Date: 2013-04-12 18:12:42
Message-ID: CAGo0LBQauGMyD89HLHa=CM7yB9eEKMnx5hgq1QY0wZ7RfroixQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)albe(at)wien(dot)gv(dot)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
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Alvaro Herrera 2013-04-12 18:16:59 Re: regexp_replace grief
Previous Message Mike Broers 2013-04-12 17:34:38 Re: [ADMIN] after 9.2.4 patch vacuumdb -avz not analyzing all tables