From: Szymon Drejewicz Date: 2004-04-23T21:19:04+09:00 Subject: Re: [NEWBIE] Extract all occurences from a text My favourite method for extracting regexps and processing them is gsub() with block: File.open("fileName.html","r").readlines.join.each_line do |line| line.gsub(/yourPattern/) do |match| ...do something with 'match' end end