From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
---|---|
To: | CaT <cat(at)zip(dot)com(dot)au>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: REGEXP_REPLACE woes |
Date: | 2008-06-10 14:10:58 |
Message-ID: | 200806101610.58085.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tuesday 10. June 2008, CaT wrote:
>On Tue, Jun 10, 2008 at 03:43:02PM +0200, Leif B. Kristensen wrote:
>> 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:
>
>That makes no sense. Take this bit of perl, which works as expected:
>
>$str = '[p=123|John Smith] and [p=456|Jane Doe]';
>
>print "before: '$str'\n";
>
>$str =~ s#\[p=(\d+)\|(.+?)\]#1 = $1, 2 = $2 rest of str = #;
>
>print "after: '$str'\n";
>
>There's a bug in your version of pcre I think as postgres would have
>little to do with the regex itself (I be guessing).
I found this obscure reference in the Pg docs
<http://www.postgresql.org/docs/8.2/interactive/functions-matching.html>
"In short, when an RE contains both greedy and non-greedy
subexpressions, the total match length is either as long as possible or
as short as possible, according to the attribute assigned to the whole
RE. The attributes assigned to the subexpressions only affect how much
of that match they are allowed to "eat" relative to each other."
And it was what made me try the above approach. I agree that it doesn't
make much sense.
--
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 | Adrian Klaver | 2008-06-10 14:16:43 | Re: Re: Accessing other databases with DBLink when leaving user/password empty |
Previous Message | Michael Fuhr | 2008-06-10 14:07:07 | Re: REGEXP_REPLACE woes |