Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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:??;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://369911]
[markong]: " Perl: the Markov chain saw" :D aha
[Discipulus]: thanks 1nickt but seems i'm not able to use it correctly...
[Discipulus]: Eily i'm testing a failure: i ok if i get bad results.. perhaps there is another way to do it...
[Discipulus]: in other words: i have a contructor that carps on missing arguments and I want to test that it fails correctly, without carping out in the test output

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2018-01-22 11:31 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.