Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Christian Mächler <christian_maechler(at)hotmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
Date: 2015-08-05 01:20:51
Message-ID: 22208.1438737651@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> On Tue, Aug 4, 2015 at 8:39 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> BTW, perhaps it would be worth adding an example to that section that
>> shows how to control this behavior.

> +1

When I looked closer, I noticed that the docs already had a recommendation
about how to force overall greediness or non-greediness, and it was
cleaner than the \0* hack I'd come up with on the spur of the moment.
So I extended that with an example.

For-the-archives: it strikes me that if we ever did want to break
backwards compatibility here in order to make it act a bit more like
Perl's regexps, we could try making the concatenation rule be that the
overall RE inherits the greediness of its last quantified atom rather than
its first one. But I'm not sure how close an approximation that would
produce to Perl's engine's behavior; there would probably still be some
discrepancies. I doubt it's worth breaking backwards compatibility for,
if we'd still get complaints from Perl users that our regex engine is
broken because it's not bug-compatible with Perl's.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message John R Pierce 2015-08-05 01:26:12 Re: BUG #13538: REGEX non-greedy is working incorrectly (and also greedy matches fail if non-greedy is present)
Previous Message David G. Johnston 2015-08-05 00:40:02 Re: BUG #13533: jsonb_populate_record does not work when the value is a simple string