Skip to content

Instantly share code, notes, and snippets.

@Avi-E-Koenig
Created May 31, 2022 17:16
Show Gist options
  • Save Avi-E-Koenig/c96163ec82b4ae6f015780de8171b32c to your computer and use it in GitHub Desktop.
Save Avi-E-Koenig/c96163ec82b4ae6f015780de8171b32c to your computer and use it in GitHub Desktop.
Simple Regex Email Tester
export const isValidEmail = (emailStr) => {
const regex = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
const res = regex.test(emailStr.toLowerCase());
console.log("🚀 ~ file: validateEmail.js ~ line 5 ~ isValidEmail ~ res", res)
return res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment