From: "F. Senault" Date: 2009-03-13T17:18:04+09:00 Subject: Re: read html then output one line of html if found? Le 12 mars � 21:36, Mmcolli00 Mom a �crit : > Here is my snippet. > > require "fileutils" > > Dir["C:/Respecs/*.html"].each do |htmlfile| > readhtml = File.read(htmlfile) > if readhtml.include?("seconds") == true > htmlbase = File.basename(htmlfile) > puts htmlbase > end For the easy way, try readlines and grep : >> h = File.readlines('f1.txt') => ["

hhhhhh

\n", "

20 seconds

\n", "

Blah.

\n", "\n"] >> h.grep(/seconds/) => ["

20 seconds

\n"] For a more sophisticated (and time-consuming) approach, try an HTML parser like Hpricot : >> require "hpricot" => true >> doc = Hpricot(File.read('f1.txt')) => # "hhhhhh" } "\n" {elem

"20 seconds"

} "\n" {elem

"Blah."

} "\n\n"> >> doc.children.select { |e| e.inner_html =~ /seconds/ } => [{elem h2 "20 seconds" h2}] HTH. Fred -- Everyone is bad in their own way. Finding out each person's unique way of being bad is most of the fun of getting to know them. (Lee Wilson)