To my surprise this only works on the first iteration. Can you please let me know why? Could this have to do with the match position not getting reset? I am at a loss ...my @strings = qw( aaabbbb ab abb aabb aaabb aabbb ); for my $string ( @strings ) { my $a_counter = 0; my $b_counter = 0; print "In $string there were $a_counter 'a's and $b_counter 'b's. +\n" if ( $string =~ /(a(?{$a_counter ++;}))+(b(?{$b_counter ++;}))+/ +); }
In reply to Extracting the number of repetitions from a regex by pat_mc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |