From: Pit Capitain Date: 2005-04-21T02:29:19+09:00 Subject: Re: Linear complete variation of MatchData#to_a, possible? Trans schrieb: > > Your nesting will work too. I excluded a couple layers were I felt it > wasn't significant. I think the pre and post matches can just be the > first and last elements respectively, so another that nesting isn't > relly needed (IMHO). But you may be quite right about the next layer. I > had thought it might be dropped without issue, but perhaps it is in > fact neccessary to keep the nesting consistant with the subexpressions. > Nonetheless, yes, you have the idea. Can it be done? I'm not sure how > one would "query" the level of subexpression nesting. Hi Tom, I'd try using MatchData#begin and MatchData#end: md = /(1)(2(3))(4)/.match( "012345" ) md.size.times do |i| puts( md.begin( i ) .. md.end( i ) ) end The output is: 1..5 1..2 2..4 3..4 4..5 It should be possible to determine the splitting and the nesting out of those numbers. If you're not successful, send me a mail and I'll try to find some more time to help. Regards, Pit