I want to accept mail formats like these :
"x@x.com"
"x.x@x.com"
"x.x@x.com"
"x.x.x@x.com"
"x@x.x.x.com"
"x@x.x.com"
"etc..."
How can I modify this regex to accept dots inside emails?
@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"
thank you.
I want to accept mail formats like these :
"x@x.com"
"x.x@x.com"
"x.x@x.com"
"x.x.x@x.com"
"x@x.x.x.com"
"x@x.x.com"
"etc..."
How can I modify this regex to accept dots inside emails?
@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"
thank you.
To answer your question: when your after-@ part contains more than 1 dot, the one-char parts between the dots cannot be matched due to the {2,3}
limiting quantifier minimum threshold. It requires at least 2 chars in between the dots.
You could fix it with ^([\w.-]+)@([\w.-]+)(\.\w+)$
where all the dot parts but the last one in the domain part would appear in Group 2 and the last one will be in Group 3.
The best approach to validate an e-mail in .NET is the one described here.