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

来源:http://www.strivingprogrammers.com/articles/10-regular-expression-validator-for-checking-different-kinds-of-e-mail-address.aspx

原文:

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:

         

^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$




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: [email protected] | [email protected] | [email protected] | [email protected] | [email protected] | [email protected] | [email protected]

Non-Matches: www.domain.com | [email protected] | [email protected] | name@[email protected] | name@com

你可能感兴趣的:(Regular Expression Validator for checking different kinds of e-mail address)