in reply to Perl Regex Repeating Patterns
It shouldn't be hard to adapt if you want the offsets (as your original code does). It does capture overlapping matches, although with the given patterns, no overlap is possible.foreach my $pattern (@patterns) { for (my $i = 0; $i < length($string); $i += 3) { push @matches, ${^MATCH} if substr($string, $i) =~ /^$pattern/p; } }
|
|---|