Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Arbitrary number of captures in a regular expression

by bsb (Priest)
on Sep 25, 2007 at 10:19 UTC ( #640885=note: print w/replies, xml ) Need Help??


in reply to Arbitrary number of captures in a regular expression

It's not fancy or general, but it's simple and may be adaptable to your purpose:
$ms = '(?: m (\d+))?' x 5; # 1) print join(",", /^foo$ms bar$/ ),"\n" for ( 'foo m 1 m 2 m 3 m 4 bar', 'foo m 2 m 4 m 7 bar', 'foo m 1 bar', ); __END__ 1,2,3,4, 2,4,7,, 1,,,,
1) Where "any number" is equal to 5...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://640885]
help
Chatterbox?
[1nickt]: Config works properly, thank you. I has first followed an example from the doc using eval. THis is much nicer.
[jedikaiti]: 'ello

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2017-10-18 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (249 votes). Check out past polls.

    Notices?