Ok, using plperlu:
jeck=# select s('fred','(fr)(ed)', '$1');
s
----
fr
(1 row)
jeck=# select s('fred','(fr)(ed)', '$2');
s
----
ed
(1 row)
jeck=# select s('fred','(fr)(ed)', '$2 $1');
ERROR: plperl: error from function: syntax error at
(eval 7) line 2, near "$2 $1
"
jeck=# select s('fred','(fr)(ed)', '$2." ".$1');
s
-------
ed fr
(1 row)
So, the string to be evaluated must meet normal perl
syntactic rules for an expression.
The example you gave worked fine for me from the
command line because I was typing the "$2 $1" directly
into the regex, so one interpolation did the job. In
the function the first interpolation placed the
argument string into the regex, not the value of the
variable, so the eval (s/.../.../ee) is needed to get
the value.
Hmm, maybe this was off-topic after all ;-)
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com