develooper Front page | perl.perl5.porters | Postings from July 2018

Re: [perl #133352] Ancient Regex Regression

Thread Previous | Thread Next
David Nicol
July 17, 2018 16:58
Re: [perl #133352] Ancient Regex Regression
Message ID:
This is a good test case for the bug:

On the other hand, my patch does allow this example to match:

     print "matched\n" if "ABCDA" =~ /^ (?: (.)B | CD )* \1 $/x;

Without my patch, this matches instead:

     print "matched\n" if "ABCDC" =~ /^ (?: (.)B | CD )* \1 $/x;

The bug appears to be the result of an optimization of describing the
capture buffer with an offset -- essentially a dynamic substring expression
-- rather than copying the captured string into it.
Were the capture buffer to be copied into, it would get 'A'  (the character
before the B) rather than 'C ' (the first character in the match) and the
behavior would be the same as what the other regex engines do.

Is that what the patch changes?

"At this point, given the limited available data, certainty about only a
very small number of things can be achieved." -- Plato, and others

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About