Thread: Problem with replace

Problem with replace

From
"slawosz"
Date:
Hello,
I have to relpace string
http://example.com/index.php?module=articles&id= to string /module/ in
whole column in table. How exacly use replace? I noob in postgres, I
think it could be quite easy.
Please, help


Re: Problem with replace

From
"Merlin Moncure"
Date:
On 23 Jan 2007 13:05:41 -0800, slawosz <slawosz@gmail.com> wrote:
> Hello,
> I have to relpace string
> http://example.com/index.php?module=articles&id= to string /module/ in
> whole column in table. How exacly use replace? I noob in postgres, I
> think it could be quite easy.
> Please, help

try replace command for simple things:
Administrator=# select replace ('abcdef', 'ab', '12');
 replace
---------
 12cdef
(1 row)

(to do the whole table, do:)
update foo set bar = replace(bar, ab, '12');

for more complex things use regex_replace() (see docs)

merlin