From: Robert Klemme Date: 2002-12-11T23:38:29+09:00 Subject: Re: String.scan (Regexp again...) regexp per se can not match recursive structures. for that you need a context free grammar and an appropriate parser. i think there are parser generators for ruby. robert "Shannon Fang" schrieb im Newsbeitrag news:F165JLtosJ3Ih7jtrSB000144b2@hotmail.com... > Hi gurus, > > I used the following regexp to parse a text file: > > p=/.{4}((.{3})(.{6})(.{3})).{17}(.{16}).{13}(.).{33}(.{7}).{17}((.{3})(.{6} )(.{3}))/ > > line="PFPT0YH100010 NUT-SPRG-EXPN 980101G A > 00001000010001WA100001050000000 OYH100010 > " > result=line.match(p) > p result >> > > [["0YH100010 ", "0YH", "100010", " ", "NUT-SPRG-EXPN ", "G", > "0000105", " > ", " ", " ", " "]] > > It seems that result is flattened. I expect result like this: > [[a,b,c], d,e,f,[g,h,i]] > > Could anyone tell me how can I achieve that? Thanks a lot! > > Shannon > > _________________________________________________________________ > The new MSN 8: advanced junk mail protection and 2 months FREE* > http://join.msn.com/?page=features/junkmail > >