I wish to have the ability to parse any url with ruby to find the primary area of the domain with no world wide web (only the XXXX.com)

This will use virtually any URL:

# URL always will get parsed two times

def get_host_without_world wide web(url)

  url = "http://#" if URI.parse(url).plan.nil?

  host = URI.parse(url).host.downcase

  host.start_with?('www.') ? host[4..-1] : host

finish

Or:

# Only parses two times if url does not begin with a plan

def get_host_without_world wide web(url)

  uri = URI.parse(url)

  uri = URI.parse("http://#") if uri.plan.nil?

  host = uri.host.downcase

  host.start_with?('www.') ? host[4..-1] : host

finish

You might want to require 'uri'.

when the URL is within format http://world wide web.google.com, then you may make a move like:

a = 'http://world wide web.google.com'

puts a.split(/./)[1] + '.' + a.split(/./)[2]

Or

a =~ /http://www.(.*?)$/

puts $1