Re: regular expression substittion function?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: regular expression substittion function?
Дата
Msg-id 2712.982255179@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: regular expression substittion function?  (Bruno Wolff III <bruno@wolff.to>)
Список 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 по дате отправления:

Предыдущее
От: David Wheeler
Дата:
Сообщение: Re: Case insensitive selects?
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: Re: last UPDATE or INSERT time of a table? (not a row!)