Re: syntax error in plperl wrapper for Perl regex replace. - Mailing list pgsql-novice

From io.sys
Subject Re: syntax error in plperl wrapper for Perl regex replace.
Date
Msg-id 20180824033249.771b45f5@aps.gogo
Whole thread Raw
In response to syntax error in plperl wrapper for Perl regex replace.  ("io.sys" <io.sys@post.cz>)
Responses Re: syntax error in plperl wrapper for Perl regex replace.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
William,

Thank you for your reply.

I am familiar with "s" command of sed and with regular expressions in general. However, I
am not familiar with Perl.

My attempt to use the "s" command in my function is exactly the way you describe, i.e:

  s/regex_to_match/replacement-string-referencing-captured-groups/optional-options

I just tried to use function parameters $_[1], $_[2], $_[3] instead fixed strings.
However, it is rejected by postgre as syntax error.

Why? Must be some trivial, novice error.

R.Golis.

####################################
On Thu, 23 Aug 2018 17:05:51 -0400, William Jackson <wtjack3@gmail.com> wrote:

> The correct syntax for Perl regex substitutions is
> 
> s/pattern_to_match/string_to_replace_matches_with/
> 
> After the third slash, you may add a single letter to indicate special
> options, like g for global (matches however many times the pattern occurs
> in the string) or i for case insensitivity. However, you may at most have
> three of those slashes in your expression, with one substitution at a time.
> There are ways to do multiple substitutions by using the default variables
> for pattern matches, but it might be beyond the scope of your
> time/usefulness. You may still want to have a look at
> https://perldoc.perl.org/perlretut.html for details.
> 
> -WTJ


pgsql-novice by date:

Previous
From: "io.sys"
Date:
Subject: syntax error in plperl wrapper for Perl regex replace.
Next
From: Tom Lane
Date:
Subject: Re: syntax error in plperl wrapper for Perl regex replace.