Entry

regex for extracting root domain

If you’re new here, you may want to subscribe to my RSS feed. Thanks for visiting!I don’t remember if i’ve already posted this. Sometimes you need to extract a domain name from a url. The following regex will do just that regardless of subdomains, etc. /^[a-z0-9.-]*?[.]{0,1}([a-z0-9-]*?\.[a-z.]{2,7})$/i Share and Enjoy: These icons link to social bookmarking sites where readers […]
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

I don’t remember if i’ve already posted this.

Sometimes you need to extract a domain name from a url. The following regex will do just that regardless of subdomains, etc.

/^[a-z0-9.-]*?[.]{0,1}([a-z0-9-]*?\.[a-z.]{2,7})$/i

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*