From: George George Date: 2009-08-31T20:33:19+09:00 Subject: Re: text lines manipulation Thanks Betram This seems to work for me, dont know whether its efficient or there is a better implementation file.each_line do |line| line.chomp! case line when /^>/ then set = $' puts set else re1='(\\d+)' # Integer Number 1 re2='(-)' # Any Single Character 1 re3='(\\d+)' # Integer Number 2 re=(re1+re2+re3) m=Regexp.new(re,Regexp::IGNORECASE); if m.match(line) int1 = m.match(line)[1]; c1 = m.match(line)[2]; int2 = m.match(line)[3]; puts int1<< c1 << int2 end end end Bertram Scharpf wrote: > Hi, > > Am Montag, 31. Aug 2009, 18:46:53 +0900 schrieb George George: >> 20-56 >> >> The idea is to read each of the lines associated with each set and do >> some manipulation? > > Untested: > > file.each_line { |l| > l.chomp! > case l > when /^#/ then set = $' > else > do_sth_with set, l > end > } > > Bertram -- Posted via http://www.ruby-forum.com/.