Reputation: 437
I want to accept mail formats like these :
"[email protected]"
"[email protected]"
"[email protected]"
"[email protected]"
"[email protected]"
"[email protected]"
"etc..."
How can I modify this regex to accept dots inside emails?
@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"
thank you.
Upvotes: 1
Views: 266
Reputation: 626926
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.
Upvotes: 1