Re: replace text function

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Darren Ferguson <darren(at)crystalballinc(dot)com>
Cc: Mark Wilson <mark(at)mediasculpt(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: replace text function
Date: 2002-11-07 03:10:25
Message-ID: 3DC9D9A1.8080008@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)mascari(dot)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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mark Wilson 2002-11-07 03:51:52 Re: replace text function
Previous Message Lee Tuck 2002-11-07 03:08:58 Postgresql problems