From: John Joyce Date: 2007-08-18T06:59:39+09:00 Subject: Re: Return first line of parsing On Aug 17, 2007, at 8:59 AM, Tim Pease wrote: > On 8/17/07, Haze Noc wrote: >> mysite.each {|line| >> if line =~ /

(.+)<\/b>/ >> puts "#{$2} found at: #{$1}" >> end >> } >> >> Ok guys, Lets say the website has 50+ lines.. and i only want to >> return >> the first one, any ideas? > > %r/^(.*)$/.match(mysite)[1] > Careful, What if the site's white space has been stripped? (no CR or LF at all) or if the html/xhtml is screwy? (old html without closed elements, or just poorly formed or badly nested)