From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | polen(dot)t2006(at)freenet(dot)de |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: regexp_replace |
Date: | 2007-07-24 14:18:09 |
Message-ID: | 20070724141809.GA40095@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Jul 23, 2007 at 07:50:35AM -0700, polen(dot)t2006(at)freenet(dot)de wrote:
> I would like to change a sub-string in a text-field by using
>
> UPDATE tablename SET
> fieldname=regexp_replace(fieldname,old_sub_string,new_sub_string)
> WHERE (fieldname like '%old_sub_string%')
>
> In priniciple, it works. However, only one occurence of old_sub_string
> is replaced and further not. Which syntax has to be used to replace
> all old_sub_strings by new_sub_string in a text-field at once?
regexp_replace(fieldname, old_sub_string, new_sub_string, 'g')
For more information search for regexp_replace in the Pattern
Matching section of the Functions and Operators chapter of the
documentation.
http://www.postgresql.org/docs/8.2/interactive/functions-matching.html
--
Michael Fuhr
From | Date | Subject | |
---|---|---|---|
Next Message | Fst Procurement | 2007-07-24 14:19:17 | Re: Connection error |
Previous Message | A. Kretschmer | 2007-07-24 14:11:02 | Re: regexp_replace |