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

Re: [perl #133352] Ancient Regex Regression

Thread Previous | Thread Next
From:
Deven T. Corzine
Date:
July 22, 2018 18:59
Subject:
Re: [perl #133352] Ancient Regex Regression
Message ID:
26597_1532285967_5B54D40E_26597_80_1_CAFVdu0TypErTqm0q_D37bBxEMykR0frswPaYg_Zqza27V0mCPQ@mail.gmail.com
On Wed, Jul 18, 2018 at 2:00 PM, David Nicol <davidnicol@gmail.com> 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.

Deven

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About