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

Re: [perl #133352] Ancient Regex Regression

Thread Previous | Thread Next
Deven T. Corzine
July 22, 2018 18:59
Re: [perl #133352] Ancient Regex Regression
Message ID:
On Wed, Jul 18, 2018 at 2:00 PM, David Nicol <> wrote:
> the expression in the capture matching isn't enough; the capture has to
> match and then the outer expression has to match too.
> I'd like to think that this can be fixed by rearranging the order of things
> so the assignment to the capture group is deferred until
> the branch the capture group is in matches.

Yes, that's one possible way to fix it, but it might be tricky to
handle backtracking with nested alternations.

> "go" clobbers $1 even though "gox" is not [fg]oo, as a later alternative
> within this iteration matches
> $ perl -le '"foobargox" =~ /^ (?: ([fg]o)(o) | gox | (bar) )* /x; print
> "1:$1;2:$2;3:$3"'
> 1:go;2:o;3:bar

This is another variation of the same bug, $1 should be "fo".

> When exactly does the assignment happen?

It happens immediately and should be rolled back when backtracking.
Right now, that's not happening when it should here.


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