Re: syntax error in plperl wrapper for Perl regex replace.

From: "io(dot)sys" <io(dot)sys(at)post(dot)cz>
To: postgre novice mail list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: syntax error in plperl wrapper for Perl regex replace.
Date: 2018-08-24 01:32:49
Message-ID: 20180824033249.771b45f5@aps.gogo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2018-08-24 02:17:10 Re: syntax error in plperl wrapper for Perl regex replace.
Previous Message io.sys 2018-08-23 17:20:05 syntax error in plperl wrapper for Perl regex replace.