Search Postgresql Archives

Escaping regular expressions in plperl

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

 



How should one escape regular expressions in plperl?

In the following chunk of PlPerl code the date doesn't match  the regex:

my $endby = '2009-06-13';

my $t = spi_exec_query(qq|SELECT CASE WHEN '$endby' ~ E'.*\\d\\d\\d\\d \\-\\d\\d?\\-\\d\\d?.*' THEN '$endby'::timestamptz ELSE CURRENT_DATE::timestamptz END AS test|);

 die "$t->{rows}[0]{test}";

However, when I run the following query using PgAdmin, the date DOES match the regex.

SELECT CASE WHEN '$endby'  ~ E'.*\\d\\d\\d\\d\\-\\d\\d?\\-\\d\\d?.*'
THEN '$endby'::timestamptz ELSE CURRENT_DATE::timestamptz END AS test






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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux