
miller
User
May 24, 2011, 3:48 PM
Post #6 of 7
(10389 views)
|
Re: [rovf] Matching repetitions of an exact length
[In reply to]
|
Can't Post
|
|
Yes, you can get around the hack by using the enhanced regex that I built from yours. 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 )gx; print join(',', @runs), "\n"; =prints b,ccc,c,e,fff,f =cut It's easily solved though, just put it in a while loop so that $2 can be pulled explicitly. - M
|