From: Rolf Pedersen Date: 2010-07-05T20:52:57+09:00 Subject: Re: File data extraction --0016e65aee14b26671048aa29308 Content-Type: text/plain; charset=ISO-8859-1 Thanks Brian, that helped me a lot ! :o) The code now looks like this: filenames = File.open(filename).readlines.join.scan(/^@begin Objects\n(.*?)^@end;/m)[0][0].split("\n").map{|l| l.scan(/"(.*?)"/)[0][0]} Probably far from optimal, but it seems to do the trick. Best regards, Rolf On Mon, Jul 5, 2010 at 12:12 PM, Brian Candler wrote: > Rolf Pedersen wrote: > > My initial idea was to treat the whole thing as one long string, and > > extract > > the part within the being-end-block by using regexp, converting the > > result > > back to individual lines (split '\n') and doing array.map and regexp to > > single out the name in the first quote on each line. > > But I keep hitting the wall, especially with the first step in this > > approach... :o( > > How about this for starters: > > p src.scan(/^@begin(.*?)^@end;/m) > -- > Posted via http://www.ruby-forum.com/. > > --0016e65aee14b26671048aa29308--