I want to get just the domain name(yahoo, google, stackoverflow) from the domain in javascript. How can I easily pull just this out and drop any subdomain and any extension?
See comment, I need it to work for any domain if possible.
From stackoverflow
-
"www.google.com".match(/\.?([^.]+)\.[^.]+.?$/)[1] -
var domain = 'http://www.google.com/'; var parts = domain.toString().split('.'.toString()); parts[parts.length - 2];
0 comments:
Post a Comment