From: Damjan Rems Date: 2008-08-11T15:53:06+09:00 Subject: Re: Regex. How to return multiple lines Robert Klemme wrote: > On 10.08.2008 15:49, Sebastian Hungerecker wrote: >> Robert Klemme wrote: >>> c = File.read "x" >>> >>> p c.grep /a+/ >> >> Why not: >> p File.open("x") {|f| f.grep /a+/} >> Avoids loading the whole file into memory. > > The original request stated "I assume that file would be read in one > chunk into memory." which I choose to respect. But see my disclaimer at > the end and also my other reply that hinted at this. > > Cheers > > robert Thank you very much guys. As I wrote I assume that data would reside in the memory for the life of a program. Since search argument would be entered by user the final result looks close to this: what = get_from_input() r = Regexp.new(what, true) a = s.grep(r) by TheR -- Posted via http://www.ruby-forum.com/.