Обсуждение: regex from plperl

Поиск
Список
Период
Сортировка

regex from plperl

От
"Ferruccio Zamuner"
Дата:
Hi,

I've written following function:

create or replace function dewey(text)
   returns text
   as '
 $_=shift;
 if (/(\d\d\d)/) {
    return "$1";
 } else {
    return("this is not a valid dewey!");
 }' language plperlu;

Then:

libri=# select dewey('432');
           dewey
----------------------------
 this is not a valid dewey!
(1 row)


It seems that regex doesn't work at all.

But regex are quite important for me.
Is There something that I've forgotten?


Best wishes,              \fer
--


Re: regex from plperl

От
Tom Lane
Дата:
"Ferruccio Zamuner" <nonsolosoft@diff.org> writes:
> create or replace function dewey(text)
>    returns text
>    as '
>  $_=shift;
>  if (/(\d\d\d)/) {
>     return "$1";
>  } else {
>     return("this is not a valid dewey!");
>  }' language plperlu;

You need to double the backslashes.

            regards, tom lane