From: Simon Strandgaard Date: 2004-09-23T04:52:52+09:00 Subject: Re: Regexp Arity On Wednesday 22 September 2004 21:47, David A. Black wrote: > > writes: > > > |Just ran into a need to know how many parenthetical groupings a Regexp > > > | has. Would #arity for Regexp be a good idea? [snip] > > Hmm... that brings up a good point. Would zero-width positive lookheads > > and/or non-backreferencing groups be counted? > > To back up slightly: I can't help wondering under what conditions you > would need to know this. Can you present the problem you were trying > to solve? Maybe there's a simpler way. Maybe I should advertise some more for my regexp package irb(main):001:0> require 'regexp' => true irb(main):002:0> puts /this(feels(like)lisp|scheme)/.tree +-Sequence +-Inside set="t" +-Inside set="h" +-Inside set="i" +-Inside set="s" +-Group capture=1 +-Alternation +-Sequence | +-Inside set="f" | +-Inside set="e" | +-Inside set="e" | +-Inside set="l" | +-Inside set="s" | +-Group capture=2 | | +-Sequence | | +-Inside set="l" | | +-Inside set="i" | | +-Inside set="k" | | +-Inside set="e" | +-Inside set="l" | +-Inside set="i" | +-Inside set="s" | +-Inside set="p" +-Sequence +-Inside set="s" +-Inside set="c" +-Inside set="h" +-Inside set="e" +-Inside set="m" +-Inside set="e" => nil irb(main):003:0> to install just type rpa install re -- Simon Strandgaard