Click here to Skip to main content
15,064,140 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Regular Expression for Email Format Validation using ASP.NET 4.0.,,, or uk or nz

It will fail for rest all like it should not start with numbers,not special symbols except _(underscore). And also the domainname can't be in domain_name or domain-name or domain!@#$name. Rest all need to accepted.

I had tried by this (\w+[-+.]?)+@\w+([-.]\w+)*\.\w+([-.]\w+)* expression. But here I can access numbers, special characters in initial value.
Updated 5-Oct-12 3:00am
OriginalGriff 5-Oct-12 6:05am
And what have you tried?
Mannava Siva Aditya 5-Oct-12 9:00am
I had tried by this (\w+[-+.]?)+@\w+([-.]\w+)*\.\w+([-.]\w+)* expression. But here I can access numbers, special characters in initial value.
Paresh Lahade 5-Oct-12 6:08am
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
Mannava Siva Aditya 5-Oct-12 9:08am
Can you be more presize and I want to make it in client side.
Keith Barrow 17-Jun-13 8:20am has a searchable library of regexs, with descriptions of how they operate (including limitations etc) as well as ratings. Searching for e-Mail produces 8 pages of results at 20 results per page. About 20 of these have a 5-star rating. You can just peform a basic check on the client side and a full code-based check on the server if you get desperate...
Mannava Siva Aditya 17-Jun-13 9:02am
Keith Thanks for providing the information.

Try on google[^] first Mannava, it will give you huge search results in quick time. And most of the threads will solve your problem quite easily. Take a look.
Mannava Siva Aditya 5-Oct-12 9:04am
I had done the same but in most of all threads, when I test the email I am able to enter integers in initial, special symbols too. I want to restrict those we are not suppose to enter such things.
U didnt mention your code for email pattern match..
Hence i m giving u following pattern try it out..n let me know its helping u or not.
string pattern = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
Mannava Siva Aditya 5-Oct-12 9:02am
Aysha Patel in your patter we can write, its been accepted. but an email should not start with numbers, or special symbols except _ (underscore)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900