From: | matt(at)byrney(dot)com |
---|---|
To: | "Jasen Betts" <jasen(at)xnet(dot)co(dot)nz> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: regex help wanted |
Date: | 2013-04-28 17:29:44 |
Message-ID: | bae5a6ebce3e67ef0fd79a3d3c880727.squirrel@mail.byrney.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 2013-04-25, Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
>> On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote:
>>
>>> Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> writes:
>>> > What I don't understand is: Why does the following return a
>>> > substring ?
>>>
>>> > select substring ('junk $<allergy::test::99>$ junk' from
>>> '\$<[^<]+?::[^:]+?>\$');
>>>
>>> There's a perfectly valid match in which [^<]+? matches allergy::test
>>> and [^:]+? matches 99.
>>
>> Tom, thanks for helping !
>>
>> I would have thought "<[^<]+?:" should mean:
>>
>> match a "<"
>> followed by 1-n characters as long as they are not "<"
>> until the VERY NEXT ":"
>
>
> if you want that say: "<[^<:]+:"
>
>> The "?" should make the "+" after "[^<]" non-greedy and thus
>> stop at the first occurrence of ":", right ? Or am I
>> misunderstanding that part ?
Greediness and non-greediness of operators are like hints - they are only
honoured if there is a choice in the matter. In your case, if the
<[^<]+?: stopped at the first ":", it would be impossible to match the
rest of the pattern.
From | Date | Subject | |
---|---|---|---|
Next Message | Martín Marqués | 2013-04-28 19:18:18 | Re: apt.postgresql.org broken dependency? |
Previous Message | Tom Lane | 2013-04-28 15:22:46 | Re: Missing WAL files - file-based replication |