Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Count capturing parentheses in a compiled regexp

by japhy (Canon)
on Jun 27, 2004 at 03:35 UTC ( #369911=note: print w/ replies, xml ) Need Help??


in reply to Count capturing parentheses in a compiled regexp

In the spirit of "match the regex to get the number of parens in it", here's another way:

sub nparens { "" =~ /|$_[0]/ and $#+ }
_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;


Comment on Re: Count capturing parentheses in a compiled regexp
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-07-07 15:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls