Re: regexp_replace

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "a_ogawa00" <a_ogawa00(at)yahoo(dot)co(dot)jp>, pgsql-patches(at)postgresql(dot)org
Subject: Re: regexp_replace
Date: 2005-06-06 15:34:47
Message-ID: 200506061534.j56FYlf14794@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Your patch has been added to the PostgreSQL unapplied patches list at:
>
> > a_ogawa00 wrote:
> >> This patch provides a new function regexp_replace.
> >> regexp_replace extends a replace function and enables text search
> >> by the regular expression. And, a back reference can be used within
> >> a replace string.
> >> (This patch for PostgreSQL 7.4.3)
>
> Don't we have this functionality already? It's even SQL-spec ...

Uh, all I see it replace(), which isn't regex:

<row>
<entry><literal><function>replace</function>(<parameter>string</parameter> <type>text</type>,
<parameter>from</parameter> <type>text</type>,
<parameter>to</parameter> <type>text</type>)</literal></entry>
<entry><type>text</type></entry>
<entry>Replace all occurrences in <parameter>string</parameter> of substring
<parameter>from</parameter> with substring <parameter>to</parameter>
</entry>
<entry><literal>replace( 'abcdefabcdef', 'cd', 'XX')</literal></entry>
<entry><literal>abXXefabXXef</literal></entry>
</row>

test=> SELECT replace('abc','a','d');
replace
---------
dbc
(1 row)

test=> SELECT replace('abc','[a-c]','d');
replace
---------
abc
(1 row)

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-06-06 15:39:27 Re: regexp_replace
Previous Message Bruce Momjian 2005-06-06 15:25:07 Re: [COMMITTERS] pgsql: Fix NUMERIC modulus to properly truncate

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-06-06 15:39:27 Re: regexp_replace
Previous Message Bruce Momjian 2005-06-06 15:28:49 Re: (8.1) to_timestamp correction (epoch to timestamptz)