Re: Escaping regular expressions in plperl

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Escaping regular expressions in plperl
Дата
Msg-id 10595.1244990905@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Escaping regular expressions in plperl  (Toomas Vendelin <pg@vendelin.com>)
Список pgsql-general
Toomas Vendelin <pg@vendelin.com> writes:
> 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|);

Backslash is an active escape character in qq constants, no?  You'd need
to double all those backslashes, or choose a different quoting method
for the query.  (And I hope this is all encased in dollar quoting for
the function body...)

            regards, tom lane

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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: [sfpug] "Rails and PostgreSQL" now up on media.postgresql.org
Следующее
От: sergio nogueira
Дата:
Сообщение: terminating connection because of crash of another server process