Re: Replacing characters in a string - Mailing list pgsql-general

From Michele Petrazzo - Unipex
Subject Re: Replacing characters in a string
Date
Msg-id 4C8F5BC1.3030703@unipex.it
Whole thread Raw
In response to Replacing characters in a string  (Luís de Sousa <luis.a.de.sousa@gmail.com>)
Responses Re: Replacing characters in a string
List 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


pgsql-general by date:

Previous
From: Sergey Konoplev
Date:
Subject: Re: Replacing characters in a string
Next
From: Bill Moran
Date:
Subject: Re: What filesystem to use for postgres?