Advertisement
CR7CR7

simpleRegex

Sep 4th, 2023
3,226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function validateEmail(email) {
  2.   // Regular expression to match a valid email address
  3.   const regex = /^[a-zA-Z0-9.]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
  4.  
  5.   // If the email address does not match the regular expression, return false
  6.   if (!regex.test(email)) {
  7.     return false;
  8.   }
  9.  
  10.   // Otherwise, the email address is valid, so return true
  11.   return true;
  12. }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement