Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Trying to count the captures in a compiled regular expression

by hv (Parson)
on May 03, 2004 at 08:31 UTC ( #349963=note: print w/replies, xml ) Need Help??


in reply to Re: Trying to count the captures in a compiled regular expression
in thread Trying to count the captures in a compiled regular expression

Very nice. :)

You can go a step better by making the outer match minimal, which means it will immediately match zero times and thus avoid the time and danger of trying to match the interior at all:

@capture_count = /($regex)??/; print @capture_count - 1, " captures\n";

Hugo

  • Comment on Re: Re: Trying to count the captures in a compiled regular expression
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://349963]
help
Chatterbox?
[Lady_Aleena]: How is velco protective? It sticks to a lot of things.
[beech]: cant be tyed to a fencepost by my feet, duh

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2017-06-23 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (539 votes). Check out past polls.