Skip to content

Instantly share code, notes, and snippets.

@Dottenpixel
Forked from argshook/matchEmail.js
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save Dottenpixel/3df3719bb27c3fe39b14 to your computer and use it in GitHub Desktop.

Select an option

Save Dottenpixel/3df3719bb27c3fe39b14 to your computer and use it in GitHub Desktop.
// regexp for matching a valid email and populating an array with its parts
'e.mail-address@my-domain.co.us'.match(/([a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*)+\@([a-z0-9-]+)\.([a-z.]{2,})/)
// returns ['e.mail-address@my-domain.co.us', 'e.mail-address', 'my-domain', 'co.us']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment