Skip to content

Commit c1235a2

Browse files
authored
Merge pull request #3 from lgope/before-marster
email validate with regex 🛠
2 parents 173556d + 4f1ae51 commit c1235a2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function validateEmail(email) {
2+
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
3+
return re.test(String(email).toLowerCase());
4+
}
5+
6+
console.log(validateEmail('example@example.com')); // true
7+
console.log(validateEmail('example12121@gmail.com')); // true
8+
console.log(validateEmail('example121.gmail.com')); // false

0 commit comments

Comments
 (0)