| From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: REGEXP_REPLACE woes |
| Date: | 2008-06-10 13:43:02 |
| Message-ID: | 200806101543.02354.leif@solumslekt.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Tuesday 10. June 2008, Leif B. Kristensen wrote:
>Hey, I told it not to be greedy, didn't I?
Found it. I must make *both* atoms non-greedy:
pgslekt=> CREATE OR REPLACE FUNCTION link_expand(TEXT) RETURNS TEXT AS
$$
SELECT REGEXP_REPLACE($1,
E'\\[p=(\\d+?)\\|(.+?)\\]',
E'<a href="./family.php?person=\\1">\\2</a>', 'g');
$$ LANGUAGE sql STABLE;
CREATE FUNCTION
pgslekt=> select link_expand('[p=123|John Smith] and [p=456|Jane Doe]');
link_expand
-----------------------------------------------------------------------------------------------------
<a href="./family.php?person=123">John Smith</a> and <a
href="./family.php?person=456">Jane Doe</a>
(1 row)
It's not totally intuitive, but at least now it works.
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE
My Jazz Jukebox: http://www.last.fm/user/leifbk/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | CaT | 2008-06-10 14:02:44 | Re: REGEXP_REPLACE woes |
| Previous Message | Michael Fuhr | 2008-06-10 13:41:53 | Re: REGEXP_REPLACE woes |