Sergey Konoplev writes:
> Just specify 'g' as the flags parameter (the 4th one). It means 'globally'.
> SELECT regexp_replace('xaxx', 'x', 'e', 'g');
> There are more of this flags described here:
> http://www.postgresql.org/docs/8.4/interactive/functions-matching.html#POSIX-EMBEDDED-OPTIONS-TAB
Thank you for all the answers, several ways this can be made.
Luís
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
2010/9/14 Luís de Sousa
> 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
Hello
2010/9/14 Luís de Sousa :
> 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_re
2010/9/14 Luís de Sousa :
> 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
>
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
---
2010/9/14 Luís de Sousa :
>> 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 specify 'g' as the flags parameter (the 4th one). It means 'globally'.
SELECT regexp_replace('xaxx', 'x', 'e',
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