Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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?
[moritz]: seems there's a size limit for hostenum, and the error message just sucks
[vrk]: None, other than the location of the error: auto/NetAddr/IP/ _splitref.al
[vrk]: Aha, there's a reference to "bug report 82719" in NetAddr/IP.pm's sub _splitref.
[moritz]: wow, that's their idea of an "improved error message"
[moritz]: how about "This network is too large to enumerate all host addresses." or so?
[vrk]: Well, there's a call to notcontiguous() before the error, whose description is "counts the bit positions remaining in the mask when the rightmost '0's are removed"
[vrk]: Clear as mud!

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-04-25 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (449 votes). Check out past polls.