Regex for the e-mail identifier that will only allow specific numbers of points (1-5) after @ the sign

advertisements

People have discussed a lot on Regex for email validations. I found many ideal regex for email id but all of them are validating email id having more than 2 dots i.e.

[email protected]

All regex are validating this email id which is not right.

its a wrong email id according to me, i understand there can be sub -sub -sub domains , but still more than 5 dots should not be allowed.

i want this thing to be controlled and only 1 to 5 dots can be entered after the @ sign.

so how this can be done using regex ?

Thanks in advance. i hope that stackoverflow will solve this problem for sure.

-Sangram


See if this can help. (Mind you it's is a reduced down validation)

\A[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.){1,5}[A-Za-z]{2,4}\Z