Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Arbitrary number of captures in a regular expression

by Sidhekin (Priest)
on Sep 23, 2007 at 20:59 UTC ( #640613=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my (@match) = $str =~ /(?:^foo |(?<!^)\G)m (\d+) (?=(?:m \d+ )*bar)/g;
    
  2. or download this
    my @test = ( 'foo m 1 m 2 m 3 m 4 bar',
                 'foo m 2 m 4 m 7 bar',
    ...
      local $" = ', ';
      print "'$str' => (@match)\n";
    }
    
  3. or download this
    'foo m 1 m 2 m 3 m 4 bar' => (1, 2, 3, 4)
    'foo m 2 m 4 m 7 bar' => (2, 4, 7)
    ...
    'foo m 1 c 2 bar' => ()
    'foo m 1 bar m 2' => (1)
    'foo m 1 m 5 m 7' => ()
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-11-27 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (182 votes), past polls