From: Florian Frank Date: 2004-09-23T09:55:53+09:00 Subject: Re: Regexp Arity On Thu, 2004-09-23 at 02:03, Nikolai Weibull wrote: > * Gavin Sinclair [Sep 23, 2004 01:50]: > > > Regexp#groups ? > > > Regexp#groupcount? > > > > Regexp#ngroups > > Best by far, so far, Which groups are counted here? There are capturing groups and non-capturing groups. Or is this the sum of those two numbers? At the moment I don't see any obvious reason to count those groups in a Regexp at all. I should know everything about them before I created the regexp. If I want to find out how many captures I got after matching the regexp I can easily get that info from MatchData#captures.size. On the other hand the grouping is a tree structure and if I simply compute one number from a regexp I loose a lot of information. They can be quite complicated like /(((a))(?:(b|c)|d))/. From the group size alone I cannot infer very much about the values that will be captured after a match. Simons tree construction example makes much more sense if one wants to examine the structure of a regexp. -- Florian Frank Private Linux Site