From: kranthi reddy Date: 2009-04-25T16:21:24+09:00 Subject: Re: Needed only the Domain name from an url --00163628517c269d5e04685bdc6a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit If you are using a rails app then something similar to this can be done: In the application controller private def locate_subdomain end On Fri, Apr 24, 2009 at 6:01 PM, Raveendran Perumalsamy < jazzezravi@gmail.com> wrote: > Srikanth Jeeva wrote: > > hi, > > Suppose if i give, > > url="www.google.com/picasa/images/1" > > > > I need only the string "google" which is the domain name. > > > > right now i have tried this, > > > > require 'rubygems' > > require 'uri' > > url = "http://www.google.com/picasa/images/1" > > puts url = URI.parse(url).host > > ----------- > > output: "google.com" > > ----------- > > but i want only the word "google". please help. > > > > Pts: > > the domain name can also be, "google.co.in" > > ie) for example, "http://www.google.co.in/picasa/images/1" > > > > Thanks in advance, > > srikanth > > > > Hi Sri, > > Are you got the solution ? > > If Yes, then update here about it.. > > Regards > P.Raveendran > http://raveendran.wordpress.com > -- > Posted via http://www.ruby-forum.com/. > > --00163628517c269d5e04685bdc6a--