On Aug 17, 8:52 am, Haze Noc <h... / the-c0re.org> wrote:
> mysite.each {|line|
>   if line =~ /<p><a href="(.+)"><b>(.+)<\/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?
> --
> Posted viahttp://www.ruby-forum.com/.

If you want to use essentially the same block as above, but just take
the first matching line:

mysite.each {|line|
  if line =~ /<p><a href="(.+)"><b>(.+)<\/b>/
    puts "#{$2} found at: #{$1}"
    break
  end
}

Tim's solution would give you the first line of the actual html file
and, as John mentions, that could be the entire web page if there are
no CR/LF characters in the file.

Jeremy