Re: syntax error in plperl wrapper for Perl regex replace.
"io.sys" <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.novice |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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