Re: regexp_replace grief

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux