From: Wes Gamble Date: 2006-04-18T01:04:57+09:00 Subject: Re: Regular expression to parse out "host" part of URL strin 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 -- Posted via http://www.ruby-forum.com/.