Help for this page

Select Code to Download


  1. or download this
    my @strings = qw( aaabbbb ab abb aabb aaabb aabbb );
    
    ...
    {
        print "In $string there were $a_counter 'a's and $b_counter 'b's.\
    +n" if ( $string =~ /(a(?{$a_counter ++; }  ))+(b(?{$b_counter ++;}))+
    +/ );
    }
    
  2. or download this
    In aaabbbb there were 3 'a's and 4 'b's.
    In ab there were 4 'a's and 5 'b's.
    ...
    In aabb there were 7 'a's and 9 'b's.
    In aaabb there were 10 'a's and 11 'b's.
    In aabbb there were 12 'a's and 14 'b's.