io.sys
2018-08-23 17:20:05 UTC
Hi,
I am trying to create a simple wrapper to use Perl regexp replace capabilites, which
supports \L (aka "lowercase from here on") in a replacement-strings, not available in
postgre native regexp functions.
Based on this article:
https://www.anchor.com.au/blog/2013/09/extending-postgresql-high-level-languages-cats/
I copy-pasted the function code with a little adjustment, leading to:
----------
create or replace function perl_regexp_replace (text, text, text, text)
returns text as $funcbody$
$_=$_[0];
s/$_[1]/$_[2]/$_[3];
return $_;
$funcbody$ language plperl immutable;
----------
When running the above code, I get a syntax error in the line "s/..".
When I remove this line, the function compiles, but (of course) does not do anything
usefull.
So, what is wrong with line:
s/$_[1]/$_[2]/$_[3];
Thank in advance for reply.
R.Golis, Prague.
I am trying to create a simple wrapper to use Perl regexp replace capabilites, which
supports \L (aka "lowercase from here on") in a replacement-strings, not available in
postgre native regexp functions.
Based on this article:
https://www.anchor.com.au/blog/2013/09/extending-postgresql-high-level-languages-cats/
I copy-pasted the function code with a little adjustment, leading to:
----------
create or replace function perl_regexp_replace (text, text, text, text)
returns text as $funcbody$
$_=$_[0];
s/$_[1]/$_[2]/$_[3];
return $_;
$funcbody$ language plperl immutable;
----------
When running the above code, I get a syntax error in the line "s/..".
When I remove this line, the function compiles, but (of course) does not do anything
usefull.
So, what is wrong with line:
s/$_[1]/$_[2]/$_[3];
Thank in advance for reply.
R.Golis, Prague.