Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Extracting the number of repetitions from a regex

by pat_mc (Pilgrim)
on Dec 18, 2008 at 20:30 UTC ( [id://731378]=note: print w/replies, xml ) Need Help??

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.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://731378]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found