Last active
March 7, 2018 05:53
-
-
Save waqas385/4a0521f05015c4af1660103e60424fbb to your computer and use it in GitHub Desktop.
Simple regular expression to validate email using JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/^\w+@[a-zA-Z]+\.(com|org|net)$/.test("foo@bar.com") | |
/* | |
* It will validate email of following pattern | |
* 1- Starting with any word | |
* 2- Must contains @ | |
* 3- Must contains characters a-z & A-z after @ | |
* 4- Must contains . | |
* 5- Ends with either (com, org or net) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment