Skip to content

Instantly share code, notes, and snippets.

@ManasJayanth
Last active December 30, 2015 13:01
Show Gist options
  • Select an option

  • Save ManasJayanth/5ed584315093c1eda37f to your computer and use it in GitHub Desktop.

Select an option

Save ManasJayanth/5ed584315093c1eda37f to your computer and use it in GitHub Desktop.
RegExp to extract domain from a url
function extractDomain(url) {
return url.match(/(www\.)?([a-z0-9]+\.)+[a-z]{2,}/)[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment