I would like to match just the root of a URL and not the whole URL from a text string. Given:
http://www.youtube.co
// use this if you know you have a subdomain // www.domain.com -> domain.com function getDomain() { return window.location.hostname.replace(/([a-zA-Z0-9]+.)/,""); }