With the help from this answer I'm getting clean domain names from urls in strings, like the following:
url = "http://www.stackoverflow.com/questions/ask"
var matches = url.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
return matches ? matches[1] : url;
>> "www.stackoverflow.com"
I would like to remove the subdomain "www" (and the following dot) as well though, if existing. How would I change the above expression to accomplish this?