in reply to Regex: Overlapping Matches: Double Execution of Eval-ed Code
Simplistically, it is caused by the required backtracking. How many times it gets called is also dependant upon its relative position:
#! perl -sw use strict; use re 'eval'; my $s = 'abcdef'; our $n; $n = 0; my @groups = $s =~ m[(?{ print ++$n, ' '; })(?=(..))]g; print + $/; $n = 0; @groups = $s =~ m[(?=((?{ print ++$n, ' '; })..))]g; print + $/; $n = 0; @groups = $s =~ m[(?=(.(?{ print ++$n, ' '; }).))]g; print + $/; $n = 0; @groups = $s =~ m[(?=(..(?{ print ++$n, ' '; })))]g; print + $/; $n = 0; @groups = $s =~ m[(?=(..))(?{ print ++$n, ' '; })]g; print + $/; __END__ C:\test>junk57 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
|
|---|