regex string email code example

Example 1: email regex

//Author: Mohammad Arman Khan
//Regular Expresssion for e-mail validation
var email_validator_regex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;

Example 2: regular expression for email

^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$

Example 3: email validation regex

const emailRegex = RegExp(
    /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
  );

Example 4: email regex

[\w._%+-]+@[\w.-]+\.[a-zA-Z]{2,3}