Re: Replacing characters in a string

From: Michele Petrazzo - Unipex <michele(dot)petrazzo(at)unipex(dot)it>
To: Luís de Sousa <luis(dot)a(dot)de(dot)sousa(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Replacing characters in a string
Date: 2010-09-14 11:25:53
Message-ID: 4C8F5BC1.3030703@unipex.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Luís de Sousa ha scritto:
> Hello everyone,
>
> I need to replace all occurrences of a certain character in a string.
> For that I'm using regexp_replace, but so far I only managed to
> replace the first character, here's an example:
>
>> SELECT regexp_replace('xaxx', 'x', 'e');
> regexp_replace
> ----------------
> eaxx
> (1 row)
>
> But the result I'd need is 'eaee'. How can I do it?
>

Using the right function? :)

test=# SELECT replace('xaxx', 'x', 'e');
replace
---------
eaee
(1 row)

Your usage involving regexp!

P.s. google for "replace string postgresql" and I'm feeling lucky

> Thanks,
>
> Luís
>

Michele

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Howard Cole 2010-09-14 11:57:46 Int to Interval conversion
Previous Message Sergey Konoplev 2010-09-14 11:23:52 Re: Replacing characters in a string