Geeks With Blogs
Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

original artickle:

http://www.cambiaresearch.com/c4/bf974b23-484b-41c3-b331-0bd8121d5177/Parsing-Email-Addresses-with-Regular-Expressions.aspx

            public bool TestEmailRegex(string emailAddress)

            {

//                string patternLenient = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";

//                Regex reLenient = new Regex(patternLenient);

                  string patternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+"

                        + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"

                        + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"

                        + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"

                        + @"[a-zA-Z]{2,}))$";

                  Regex reStrict = new Regex(patternStrict);

 

//                      bool isLenientMatch = reLenient.IsMatch(emailAddress);

//                      return isLenientMatch;

 

                        bool isStrictMatch = reStrict.IsMatch(emailAddress);

                        return isStrictMatch;

 

            }

 

 

Posted on Friday, March 16, 2007 11:18 AM regex - regular expressions | Back to top


Comments on this post: c# regex email address

# re: c# regex email address
Requesting Gravatar...
Thanks for the snippet. Worked perfectly!
Left by Doug on Feb 02, 2008 3:04 PM

# re: c# regex email address
Requesting Gravatar...
You solved my problem, Thanksssss
Left by Shiva Varshovi on May 04, 2008 5:02 PM

# re: c# regex email address
Requesting Gravatar...
nice code body
Left by Ali on May 20, 2008 3:22 AM

# re: c# regex email address
Requesting Gravatar...
thanks man,
you solved my problem too
keep doin' a good job helping the people :D

Left by leo on Jul 18, 2008 7:50 AM

# re: c# regex email address
Requesting Gravatar...
ths, good article
Left by asp.net c# .net framework on Aug 09, 2008 11:36 PM

# re: c# regex email address
Requesting Gravatar...
It is very usefull and great patterns like this.
Left by Guf on Sep 04, 2008 1:07 AM

# re: c# regex email address
Requesting Gravatar...
How could I change the strict pattern to allow just certain domains like .net, .com, and .org ?
Left by Hank on Sep 23, 2008 7:29 AM

# re: c# regex email address
Requesting Gravatar...
Tnx for the tip
Left by Madboy on Dec 07, 2008 12:15 AM

# re: c# regex email address
Requesting Gravatar...
Sweet, worked like a charm
Left by Raphael on May 31, 2009 10:50 PM

# re: c# regex email address
Requesting Gravatar...
this is good code thank you so much
Left by ali on Aug 01, 2009 10:58 AM

# re: c# regex email address
Requesting Gravatar...
ok. what about umlauts and some french symbols??
Left by sergey on Aug 26, 2009 12:22 PM

# re: c# regex email address
Requesting Gravatar...
Thank you...
Left by lan on Oct 01, 2009 12:37 AM

# re: c# regex email address
Requesting Gravatar...
Great post! Thanks for the code! Great work!
http://www.youtube.com/watch?v=PZ6HH6rcMUc
Left by jadenn on Dec 01, 2009 11:22 PM

# re: c# regex email address
Requesting Gravatar...
Lan, Thank you too. I really appreciate it.
Left by megaphone on Jun 26, 2010 8:18 AM

# re: c# regex email address
Requesting Gravatar...
I like that exquisite and user-friendly style you've got on this blog. I enjoyed this article particularly. I'm very interested in this subject and searching the net to find something useful. Thank you for this info.
Left by writing guide on Jun 28, 2010 5:26 AM

# re: c# regex email address
Requesting Gravatar...
Really amazing dude it really love the matter that is discussed in this post.
Left by jewelry for nipple on Nov 16, 2010 12:35 AM

# re: c# regex email address
Requesting Gravatar...
I want to know whether we can send a email through windows application

dover de hotels
Left by dover de hotels on Nov 26, 2010 6:08 AM

# re: c# regex email address
Requesting Gravatar...
Really i were wondering for this function only for testing a email validation thank for sharing this code
Left by Franklin Pumps on Dec 02, 2010 7:18 AM

# re: c# regex email address
Requesting Gravatar...
After declaring this function how to call this function to email textbox
Left by fulfillment service on Dec 09, 2010 2:54 AM

# re: c# regex email address
Requesting Gravatar...
Same way i want the coding for how to sent mail in wins form in c#
Left by lebanon pa townhomes for sale on Dec 10, 2010 4:08 AM

# Mrs
Requesting Gravatar...
I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
Left by pay for performance seo on Dec 16, 2010 6:39 AM

# re: c# regex email address
Requesting Gravatar...
original artickle:
Left by Alpha lipoic acid on Jan 06, 2011 2:01 AM

# re: c# regex email address
Requesting Gravatar...
Hey this is great stuff, very informational! I will definitely follow it, Thanks for all of your hard work and keep up the good work.
Left by beat maker on Mar 07, 2011 6:32 AM

# re: c# regex email address
Requesting Gravatar...
Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
Left by cystitis natural cure on Apr 04, 2011 11:43 PM

# sonia
Requesting Gravatar...
Thanks for posting this. i really had good time reading this.Great,
Left by ukraine florist on Apr 14, 2011 5:16 AM

# re: c# regex email address
Requesting Gravatar...

This is a great blog with excellent posts and links.
Thanks for sharing.
Left by mothers day flowers France on Apr 16, 2011 3:10 AM

# re: c# regex email address
Requesting Gravatar...
Thank you very much for your sharing. I agree with you. This is raeally a great post.
Left by Editing services on Apr 21, 2011 7:42 AM

# re: c# regex email address
Requesting Gravatar...
Thank fro your post.
with this address 78474FRANCHISING@-BATA.IT, the check is true but my email server say not.
Left by G Luca on Apr 21, 2011 7:55 AM

# re: c# regex email address
Requesting Gravatar...


Hey great stuff, thank you for sharing this useful information and i will let know my friends as well.
Left by send fathers day flowers qatar on May 27, 2011 1:18 AM

# re: c# regex email address
Requesting Gravatar...
Thanks man, it solves my issue also. just to appreciate u.
Left by hema on Jun 18, 2011 3:56 PM

# re: c# regex email address
Requesting Gravatar...
If i Enter Email like this then
anil.rathod31@yahoo.co.co.in.in
the message not giving me invalid please send me code on email id
Left by ANIL on Jul 26, 2011 3:03 AM

# re: c# regex email address
Requesting Gravatar...
I had task to write one that is shorter and more accurate and this is what I came up with. I posted about this a while ago and just had to look it up again.

http://www.rhyous.com/2010/06/15/regular-expressions-in-cincluding-a-new-comprehensive-email-pattern/
Left by Jared on Jul 31, 2011 8:14 PM

# re: c# regex email address
Requesting Gravatar...
I have to agree... the article is well written and just a pleasure to read ! I honestly really like this blog and from now on will visit it everyday. Cheers !
Left by send flowers in ireland on Aug 25, 2011 11:49 PM

# re: c# regex email address
Requesting Gravatar...
I think that thanks for the valuable information and insights you have so provided here.
Left by flowers delivery lebanon on Aug 25, 2011 11:50 PM

# re: c# regex email address
Requesting Gravatar...
This is not working correct... try enter name@company,com
Left by Guest2011 on Sep 09, 2011 5:49 AM

# Android app developers
Requesting Gravatar...
Its a interesting information and i got good knowledge to visit your blog.so i would like to thank you for the efforts which you have made in fabricated this article. I am hoping the same best assignment from you in the future as well. I look forward your next information will be a nice and great it will.
Left by Amdroid app developer on Nov 18, 2011 1:31 AM

# re: c# regex email address
Requesting Gravatar...
It does not checks for more than 3 characters after . eg test@test.commmm
Left by Aman on Dec 05, 2011 1:23 PM

# c# regex email address
Requesting Gravatar...
I think it might help me a lot in the related stuff and is particularly quite definitely useful for me. Adequately written I appreciate & must say good job..
Left by Buy Zovirax Online on Dec 19, 2011 12:09 AM

# re: c# regex email address
Requesting Gravatar...
i cant understand it could u explain me about that regex coding
Left by partha on Dec 23, 2011 11:37 AM

# re: c# regex email address
Requesting Gravatar...
Many thanks spent a while finding this for C# others are standard regex and C# escape characters cause many issues. Thanks for sharing and making the internet great
Left by Paul Cope on Jan 06, 2012 10:01 AM

# re: c# regex email address
Requesting Gravatar...
Thank you
Left by Ami on Jan 24, 2012 12:45 PM

# re: c# regex email address
Requesting Gravatar...
dgdfgd@gmail.com.gmail.com
this is not proper one extension should take .
Left by ydyd on Jul 25, 2012 5:15 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net