I am trying to write a regex to parse out the “host” part of
a potential
URL.
require ‘uri’
URI.parse(‘http://www.cnn.com’).host # www.cnn.com
URI.parse(‘http://www.cnn.com/’).host # www.cnn.com
URI.parse(‘http://www.cnn.com/some/other/stuff’).host # www.cnn.com
You’ll have to prepend the ‘http://’ yourself.
Regards,
Dan
Daniel,
I have that :).
I’m trying to handle the case when I get a “URL” without the http://
Wes
Berger, Daniel wrote:
I am trying to write a regex to parse out the “host” part of
a potential
URL.
require ‘uri’
URI.parse(‘http://www.cnn.com’).host # www.cnn.com
URI.parse(‘http://www.cnn.com/’).host # www.cnn.com
URI.parse(‘http://www.cnn.com/some/other/stuff’).host # www.cnn.com
You’ll have to prepend the ‘http://’ yourself.
Regards,
Dan