Reputation: 7683
Need to validate email address with single domain level or multi level domains.(actually domain level <=4)
Criteria:
above example there 4 domains;
I try with this RegEx:
^[a-zA-Z](:?[a-zA-Z0-9._-])+(@[a-zA-Z]+[a-zA-Z0-9_-])+\.+(([a-zA-Z]){2,6})$
But above regex not validating multiple domains correctly.It's only get 1 domain. Ex: [email protected]
Online Regex : https://regex101.com/r/7SXS1Z/1
Upvotes: 1
Views: 1805
Reputation: 43169
Maybe this is what you're looking for
^
[a-zA-Z][-.\w]* # before @
@
[a-zA-Z][-.\w]+ # first subdomain
(?:
\.[a-zA-Z][-.\w]+ # eventually others
){1,3}
$
Upvotes: 1