Re: Replacing characters in a string

From: Thom Brown <thom(at)linux(dot)com>
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:09:31
Message-ID: AANLkTimUN39268Dz8o_=tDtnZ9CwqE=RCbNp3u2_uwth@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/9/14 Luís de Sousa <luis(dot)a(dot)de(dot)sousa(at)gmail(dot)com>:
> 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?

Just remove the "regexp" bit:

SELECT replace('xaxx', 'x', 'e');

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Szymon Guz 2010-09-14 11:13:32 Re: Replacing characters in a string
Previous Message Luís de Sousa 2010-09-14 10:47:08 Replacing characters in a string