Re: Replacing characters in a string

From: Sergey Konoplev <gray(dot)ru(at)gmail(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:23:52
Message-ID: AANLkTimB5YpJ2yXUMwCQSec3USpcs6QqQwOLjRNCaQw6@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>:
>> 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', 'g');

There are more of this flags described here:
http://www.postgresql.org/docs/8.4/interactive/functions-matching.html#POSIX-EMBEDDED-OPTIONS-TABLE

p.s. The question is for hackers - BTW I did not find 'g' in this
table, is it a docs bug?

>
> Thanks,
>
> Luís
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
Sergey Konoplev

Blog: http://gray-hemp.blogspot.com /
Linkedin: http://ru.linkedin.com/in/grayhemp /
JID/GTalk: gray(dot)ru(at)gmail(dot)com / Skype: gray-hemp / ICQ: 29353802

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michele Petrazzo - Unipex 2010-09-14 11:25:53 Re: Replacing characters in a string
Previous Message Pavel Stehule 2010-09-14 11:14:09 Re: Replacing characters in a string