From: "trans. (T. Onoma)" Date: 2004-09-23T04:43:41+09:00 Subject: Re: Regexp Arity On Wednesday 22 September 2004 03:15 pm, Warren Brown wrote: > T., > > > Just ran into a need to know how many parenthetical > > groupings a Regexp has. Would #arity for Regexp be > > a good idea? > > Just to state the obvious, re.source.count('(') would work if you > can guarantee there are no literal left parenthesis ("\(") in the > regular expression. If you can't guarantee that, you could always count > them and subtract from the total, but that would be messy. And /[(]/ too. More yuk. > Perhaps we could use Regexp#length to mirror MatchData#length. At first I didn't like, but actually that could work, okay. T.