C
charles.nadeau
I have the following code snippet:
require 'net/http'
begin
hdoc =
Net::HTTP.get(URI.parse('http://finance.yahoo.com/lookup?s=Dupont&t=S&m=US'))
re = /<TD>(.*)</TD>/
if hdoc =~ re
print "#{$&}\n"
else
print "Nothing\n"
end
end
The regular expression is never matched when I use the code as shown
above (the expression for re is just a simple one for my testing).
However, if I replace the variable name hdoc by a string like
"<TD>Test</TD>Test1", the regular expression is matched. The type of
hdoc is String. What is wrong with the snippet above. I even tried to
replace hdoc by hdoc.to_s and it still doesn't work.
Thanks for your help!
Charles
require 'net/http'
begin
hdoc =
Net::HTTP.get(URI.parse('http://finance.yahoo.com/lookup?s=Dupont&t=S&m=US'))
re = /<TD>(.*)</TD>/
if hdoc =~ re
print "#{$&}\n"
else
print "Nothing\n"
end
end
The regular expression is never matched when I use the code as shown
above (the expression for re is just a simple one for my testing).
However, if I replace the variable name hdoc by a string like
"<TD>Test</TD>Test1", the regular expression is matched. The type of
hdoc is String. What is wrong with the snippet above. I even tried to
replace hdoc by hdoc.to_s and it still doesn't work.
Thanks for your help!
Charles