From: Pit Capitain Date: 2005-04-21T01:54:52+09:00 Subject: Re: Linear complete variation of MatchData#to_a, possible? Trans schrieb: > > I have a it bit of a puzzle for Regexp engine hackers out there. The > #to_a method on MatchData gives a simple list of matching portions of > the matched text. > > md = /(1)(2(3))(4)/.match "012345" > md.to_a > ["1234", "1", "23", "3", "4"] > > But I would like a method the produces a linearly segmented list of the > text itself, like this: > > ["0", "1", "2", [ "3" ], "4", "5" ] > > Notice the array depth corresponds to the subexpression depth. 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. Regards, Pit