Is there any general way to get just the base domain (without subdomain)? For example, with the following URLs (assuming no fore-knowledge about what the domains or subdomains might be...)
www.example.com
mysub.example.com
example.com
www.example.co.uk
example.co.uk
xyz.example.co.uk
For the first three, I'd like to get just "example.com", for the last, "example.co.uk", with a function that could be used in any website/server/domain.
Is it possible?