From: Dave Rose Date: 2006-11-10T04:04:57+09:00 Subject: Re: too greedy of a regexp Robert Klemme wrote: > Jan Svitok wrote: >>> ...etc.... to EOF.... >> /(^BillHead(.*?))(^Bill_End(.*?))\n/m >> >> or >> >> /(^BillHead(.*?))(^Bill_End([^\n].*))\n/m >> >> notice the .*? instead of .* >> => ["", "BillHead", "\nfoo\nbar\n", "BillEnd"] > > Kind regards > > robert i played around in irb with a shorten extract file and found that: b=File.read("drbilp.txt").scan(/(^BillHead(.*?))(^Bill_End(\d*)(\s*UBPBILP1\n)(.*?))/m) works in that separates each invoice in an sub-array of size=6 in which b[x][0]+b[x][2] completes that task of reading,scanning correctly and puting all in a ruby 'container' that i can do an each on....thanx dave -- Posted via http://www.ruby-forum.com/.