Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 ASP.NET4.0
Regular Expression for Email Format Validation using ASP.NET 4.0.
 
test@domainname.com,
test_123@domainname.com,
test.124@domainname.com,
test12.34_56test@domainname.com
test12.34_56test@domainname.co.in or uk or nz
test@196.27.2.1,
 
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.
Posted 5-Oct-12 0:04am
Edited 5-Oct-12 3:00am
v2
Comments
OriginalGriff at 5-Oct-12 6:05am
   
And what have you tried?
Mannava Siva Aditya at 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 at 5-Oct-12 6:08am
   
@"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
+ @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
+ @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?
[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
+ @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";
Mannava Siva Aditya at 5-Oct-12 9:08am
   
Can you be more presize and I want to make it in client side.
Keith Barrow at 17-Jun-13 8:20am
   
http://regexlib.com/Default.aspx 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 at 17-Jun-13 9:02am
   
Keith Thanks for providing the information.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Mannava Siva Aditya at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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])?";
  Permalink  
Comments
Mannava Siva Aditya at 5-Oct-12 9:02am
   
Aysha Patel in your patter we can write, 12@gmail.com 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)



Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 17 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100