Re: regular expression substittion function? - Mailing list pgsql-general

From Tom Lane
Subject Re: regular expression substittion function?
Date
Msg-id 2712.982255179@sss.pgh.pa.us
Whole thread Raw
In response to Re: regular expression substittion function?  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-general
Bruno Wolff III <bruno@wolff.to> writes:
> It just seemed that things would be simpler to write and understand if
> I could have used a perl like substitution function.

Why do you want a "perl-like" substitution function when you have real
Perl available?

CREATE FUNCTION perlsub(text, text, text) RETURNS text AS '
    my ($data, $pat, $repl) = $_;
    $data =~ s/$pat/$repl/;
    return $data
' LANGUAGE 'plperl';

(I'm not much of a Perl expert, but I think this is right.)

Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Added to TODO:
>    * Add sed-like regular expression search/replace capability

I fail to understand this enthusiam for building our own wheel, when
we already have a Formula I racer at hand.  Two of them, in fact.

            regards, tom lane

pgsql-general by date:

Previous
From: David Wheeler
Date:
Subject: Re: Case insensitive selects?
Next
From: Louis-David Mitterrand
Date:
Subject: Re: last UPDATE or INSERT time of a table? (not a row!)