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/