"David G. Johnston" <david.g.johnston@gmail.com> writes: > On Friday, February 2, 2018, PG Bug reporting form <noreply@postgresql.org> > wrote: >> Works as expected. Then I add |q to the pattern, and the .*? becomes >> greedy!
Yeah. That subsection also contains some useful advice about how to control greediness decisions --- in this case, wrapping the whole thing with (...){1,1}? might do what you want.
The short answer, perhaps, is that non-greedy patterns are not standardized by POSIX and you shouldn't expect that all regex engines do them the same way. Ours is definitely different from Perl's, for example.