Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by hv (Prior)
on May 03, 2004 at 08:31 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found