regex from plperl

Started by Ferruccio Zamunerover 23 years ago2 messagesgeneral
Jump to latest
#1Ferruccio Zamuner
nonsolosoft@diff.org

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
--

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ferruccio Zamuner (#1)
Re: regex from plperl

"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