From: Dave Rose Date: 2007-01-22T22:49:55+09:00 Subject: Re: Regexp.newbie? Wolfgang N叩dasi-donner wrote: > Hope there is one solution O.K. for you. > > >>>>> Code >>>>> > > mylines = < A......1 > M..... > d.... > A....1 > r.... > f.... > A.....1 > c.... > t.... > Z..... > EOT > puts '########## Without last Z-Record ##########' > mylines.scan(/^A.*?(?=^(?:A|Z))/m){|a|puts "#{a}\n----------"} > puts '########## Last Record up to EOF ##########' > mylines.scan(/^A.*?(?=^A|\Z)/m){|a|puts "#{a}\n----------"} > puts '########## Includings last Z-Record ##########' > mylines.scan(/^A.*?(?:(?=^A)|^Z.*$)/m){|a|puts "#{a}\n----------"} ...wow...thanx..a whole lot..dave -- Posted via http://www.ruby-forum.com/.