May 24, 2011, 3:48 PM
Post #6 of 7
Yes, you can get around the hack by using the enhanced regex that I built from yours.
Re: [rovf] Matching repetitions of an exact length
[In reply to]
However, list mode will still return all the capturing subgroups, not just $2.
my $letters = "aabbbbbcccdeeeeeefffgggg";
my @runs = $letters =~ m(
(.) # \1 some character
(?!\1) # negative look-ahead: next character must be different
((.)\3\3) # Run of 3 identical characters
(?!\3) # negative look-ahead: next character must be different
print join(',', @runs), "\n";
It's easily solved though, just put it in a while loop so that $2 can be pulled explicitly.