Re: replace text function - Mailing list pgsql-general

From Mike Mascari
Subject Re: replace text function
Date
Msg-id 3DC9D9A1.8080008@mascari.com
Whole thread Raw
In response to Re: replace text function  (Darren Ferguson <darren@crystalballinc.com>)
List pgsql-general
Darren Ferguson wrote:
> There is a function called TRANSLATE
>
> This will do the trick
>
> HTH

TRANSLATE performs a character-by-character replacement. You
cannot use TRANSLATE to substitute words or phrases. Example:

SELECT TRANSLATE('mikei', 'ike', '*8p');

m*8p*

all i's->*
all k's->8
all e's->p

You must either write your own replace(), or use the one
included in 7.3 as Joe Conway mentioned.

Mike Mascari
mascarm@mascari.com

>
> On Thu, 7 Nov 2002, Mark Wilson wrote:
>
>>Hi all,
>>
>>I'm trying to find a function that will replace one word with another in a
>>string.
>>
>>e.g. select <replace function>('bob was here, bobina wasnt', 'bob', 'mike');
>>will return "mike was here, mikeina wasnt"
>>
>>Is there such a function already written in PostGreSQL?


pgsql-general by date:

Previous
From: "Andrew Bartley"
Date:
Subject: bit strings
Next
From: "Mark Wilson"
Date:
Subject: Re: replace text function