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. DevenThread Previous | Thread Next