I'm looking for a lightweight way to parse a URL and extract just the domain name. The URL may be different is certain cases but I would always like the same result, for instance:
www.mysite.com ---> mysite
mysite.staging.blahblah.stuff.com:8080 ---> mysite
mysite.net ---> mysite
'mysite' will always be part of the URL and would never have more than one dot before it.