0
votes

i want a regular expression with supports the validation of a email id, the following emailids it should not support:

  1. [email protected]

  2. [email protected]

  3. [email protected]

i am using the following regex:

^([0-9a-zA-Z]+[_*|.*]{1}[0-9a-zA-Z]*|[_*|.*]|[0-9a-zA-Z]*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$

but it doesnot show all the validation

can anyone please help me?

2
There's nothing wrong with the addresses you dislike. I don't think you should reject somebody's email address just because of aesthetics. Some people don't get to pick their own address, and some have preferences different from yours. - tripleee
[_*|.*]{1} isn't sane, and probably doesn't mean what you think. I guess you want [_.]* or perhaps [_.]?. - tripleee
we cant use two underscore/dots or two special character, because these are invalid - anirbans
!#$%&'*+-/=?^_`{}|[email protected] is a valid email address. - Paul S.
Also the scope of the alternation operators is different from what you expect. ^(a[b]|c[d]|e)$ matches ab or cd or e. - tripleee

2 Answers

0
votes

got this which supports the all the validation of an email

^([a-z]+[0-9][_|.]?[a-z0-9])@[a-z]+(.[a-z]+)*(.[a-z]{2,4})$

0
votes

The following ought to do it for you :

function validateEmail(email) { 
    var 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,}))$/;
    return re.test(email);
}