SHARE
TWEET

Untitled

a guest Aug 20th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let emailRE = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
  2.  
  3. let emails = ["fernando", "fernadno@", "fernando@test", "fernando@test.com", "valid_email123@host2.com", "a@1.com"]
  4.  
  5. emails.forEach( p => {
  6.     let matches = p.match(emailRE)
  7.     if(!matches) console.log(p, "INVALID EMAIL")
  8.     else console.log(p, "is a valid email!")
  9. })
  10.  
  11. /*
  12. fernando INVALID EMAIL
  13. fernadno@ INVALID EMAIL
  14. fernando@test is a valid email!
  15. fernando@test.com is a valid email!
  16. valid_email123@host2.com is a valid email!
  17. a@1.com is a valid email!
  18. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top