From: Robert Klemme Date: 2003-12-03T23:22:07+09:00 Subject: Re: Some Regexp "Dmitry V. Sabanin" schrieb im Newsbeitrag news:200312031852.11934.sdmitry@lrn.ru... > On Wednesday 03 December 2003 17:32, Dmitry N Orlov wrote: > > TEXT1 > > some text, tabs, CRLF etc 1 > > TEXT2 > > TEXT1 > > some text, tabs, CRLF etc 2 > > TEXT2 > > TEXT1 > > some text, tabs, CRLF etc 3 > > TEXT2 > Something like this should help: > > open = "TEXT1" > close = "TEXT2" > array = data.scan(/#{Regexp::quote(open)}(.*?)#{Regexp::quote(close)}/m).flatten or: array = data.scan(/#{Regexp::quote(open)}(.*?)#{Regexp::quote(close)}/m).map{|x|x[ 0]} Directly reading from a file: IO.read("file.txt").scan(/#{Regexp::quote(open)}(.*?)#{Regexp::quote(close )}/m).map{|x|x[0]} Unfortunaltely these solutions require to read in the whole file at once. If it is guaranteed that TEXT1 and TEXT2 are always on a line by themself you can apply more efficient but a bit more comples solutions. Regards robert