REGEXP_REPLACE woes

From: "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: REGEXP_REPLACE woes
Date: 2008-06-10 11:28:06
Message-ID: 200806101328.07031.leif@solumslekt.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I want to transform the text '[p=1242|John Smith]' to
<a href="./family.php?person=1242">John Smith</a>, but what I get is:

pgslekt=> select REGEXP_REPLACE('[p=1242|John Smith]',
pgslekt(> E'[p=(\d+)|(.+?)]',
pgslekt(> E'<a href="./family.php?person=\\1">\\2</a>');
regexp_replace
------------------------------------------------------
[<a href="./family.php?person="></a>=1242|John Smith]
(1 row)

What am I doing wrong?

PostgreSQL 8.2.7 on i686-pc-linux-gnu BTW.
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE
My Jazz Jukebox: http://www.last.fm/user/leifbk/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nikola Milutinovic 2008-06-10 11:58:29 Re: Multithreaded queue in PgSQL
Previous Message IPS 2008-06-10 11:04:03 Query on Oracle 10g Merge Function equivalent command/function in Postgre