From: Joel VanderWerf Date: 2009-12-01T05:54:46+09:00 Subject: Re: regexing a file's contents without reading the whole thing? Roger Pack wrote: > I see that it is possible currently to parse through a file without > reading the whole thing into RAM, a la > > a = File.open('a', 'r') > a.lines{|line| > if line =~ /some regex/ > ... > end > } > > But what if I can to do something like > a = File.read('a').scan /some regex/ > > is that possible? > > Thanks. > -r File.open('/usr/share/dict/words').grep /ruby/i -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407