From: "David A. Black" Date: 2005-04-21T02:23:57+09:00 Subject: Re: Linear complete variation of MatchData#to_a, possible? Hi -- On Thu, 21 Apr 2005, Trans wrote: > Hi Capitain-- > > Pit Capitain wrote: >> Do you really think that you want this nesting? I'd expect something > like >> >> [ "0", [ [ "1" ], [ "2", [ "3" ] ], [ "4" ] ], "5" ] >> >> Could you try to specify the rules for your desired nesting and >> splitting? I think it should be possible to implement something like > this. > > 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. You could probably do something with MatchData#offset. The offsets of the various captures can be compared to see whether or not they overlap. No doubt there's a way to do this with inject (paging Robert K. :-) David -- David A. Black dblack@wobblini.net