From: Paul Lutus Date: 2006-10-25T14:20:11+09:00 Subject: Re: html parsing using regular expressions Anthony Walsh wrote: > I'm new to Ruby and trying to use regular expressions to parse an html > file. The page is a large table with no spaces in the html code. I want > to count the number of times or occurs. I'm stuck > on trying to match every variety of > > I've tried > > op_file = File.read(htmlfile) > if op_file =~ /()+/ > > but it catches the first file. Anyone have any advice on matching and counting? You need to tell us whether you have read the replies you received to this same question when you asked it eight hours ago. I answered your question, several others did also, you have not given any indication that you saw the replies. Here is one answer: #!/usr/bin/ruby -w path="path-to-HTML-page" data = File.read(path) array = data.scan(%r{}) puts array.size # gives a count of occurrences puts array # shows the matches Please read replies before posting again. -- Paul Lutus http://www.arachnoid.com