I\'m processing a record-based text file: so I\'m looking for a starting string which constitutes the start of a record: there is no end-of-record marker, so I use the start
you can simply do this :
message=''
while line=gets do
if line =~/hello/ then
# begin a new record
p message unless message == ''
message = String.new(line)
else
message << line
end
end
# hello this is a record
# this is also part of the same record
# hello this is a new record
# this is still record 2
# hello this is record 3 etc etc