Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Arbitrary number of captures in a regular expression

by throop (Chaplain)
on Sep 24, 2007 at 04:44 UTC ( #640658=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
                    # We're hunting the (properly bracketed)
    $str =~         # 'm \d+' occurrences.  They must be 
    ...
         (?:m \s \d+ \s)*   # Any number of m \d+ groups.
         bar)/xg;   # Finally terminated with bar (though not
                    #  necessarily the end of string.)
    
  2. or download this
      - starts at the current 'beginning' of the string
      - matches the 'm \d+' at the current position
    ...
      - matches (aft) all the remaining 'm \d+' and the final bar 
         -  and THROWS AWAY the fore and aft matches  (they're non-capturi
    +ng)
     
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-08 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls