in reply to regex backtracking question
The following variables specifies the meaning of "ABCDEF" =~ /(\w{2,}?)(?{print "$1\n"})(?!)/;for my $i (0 .. $eos) { for my $j ($min .. $max) { last if $j > $eos-$i; print substr($str, $i, $j),"\n"; } }
my $min = 2; # minimum match length my $max = 32767; # maximum match length my $str = "ABCDEF"; my $eos = length($str);
my $min = 3; # minimum match length my $max = 3; # maximum match length my $str = "ABCDEF"; my $eos = length($str);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regex backtracking question
by aeqr (Novice) on Apr 24, 2014 at 14:41 UTC |