Re: regular expression substittion function?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: regular expression substittion function?
Date: 2001-02-15 16:39:39
Message-ID: 2712.982255179@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruno Wolff III <bruno(at)wolff(dot)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(at)candle(dot)pha(dot)pa(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message pejac 2001-02-15 16:49:00 Re:TODO ITEM about substitution
Previous Message David Wheeler 2001-02-15 16:36:43 Re: Case insensitive selects?