"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tue, Aug 4, 2015 at 8:39 AM, Tom Lane <tgl@sss.pgh.pa.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