Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by ysth (Canon)
on May 03, 2004 at 16:13 UTC ( #350067=note: print w/replies, xml ) Need Help??


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

That runs in scalar context, so won't work; try:
$matches = (() = /($regex)??/) - 1;
  • Comment on Re: Explained: Trying to count the captures in a compiled regular expression
  • Download Code

Replies are listed 'Best First'.
Re: Re: Explained: Trying to count the captures in a compiled regular expression
by Roy Johnson (Monsignor) on May 03, 2004 at 17:41 UTC
    or even
    /$regex??/; print "There were $#+ groupings\n";

    The PerlMonk tr/// Advocate

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350067]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-12-16 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (447 votes). Check out past polls.

    Notices?