Re: Problem with replace

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: slawosz <slawosz(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with replace
Date: 2007-01-25 02:51:19
Message-ID: b42b73150701241851m247c5d27v1f2eccfb2c571edb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 23 Jan 2007 13:05:41 -0800, slawosz <slawosz(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2007-01-25 03:06:36 Re: Idle in transaction - Explination ..
Previous Message Ken Johanson 2007-01-25 02:28:40 Re: Example of RETURNING clause to get auto-generated keys