Regular Expression Validator for checking different kinds of e-mail address

I was working on Regular Expression Validator and found a very strong expression for checking validity of all kinds of e-mail addresses. So here i am sharing it with you guys:

Here's the expression:

Here's the way it can be used in ASP.NET Regular Expression Validator:
<asp:RegularExpressionValidator runat="server" ID="EmailAddress" Display="Dynamic" ControlToValidate="txtFirstName" ErrorMessage="Please enter a valid e-mail address" ValidationExpression="^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$"  ValidationGroup="CreateUserForm">*</asp:RegularExpressionValidator>

Matches: | | name@sub1.sub2.domain | | | name@domain.four |

Non-Matches: | | | | name@com

About Author

Written By Lavish Kumar

Based out of New York, USA, Lavish Kumar is a full stack web developer by profession and founder of Striving Programmers, a trusted community for developers that offers a wealth of articles and forums to assist individuals with improving their software development skills.

Related Blog Posts
Leave your comment