Reputation: 1166
I have been trying to find a good RegEx for email validation.
I have already gone through Comparing E-mail Address Validating Regular Expressions and that didn't suffice all my validation needs. I have Google/Bing(ed) and scan the top 50 odd results including regular expressions info article and other stuff.
So finally i used the System.Net.Mail.MailAddress
class to validate my email address. Since, if this fails, my email won't get sent to the user.
I want to customize the validation as used by the constructor of the class.
So how do I go ahead and get the validation/RegEx that the MailAddress class is using?
Upvotes: 1
Views: 1629
Reputation: 244928
According to the Reflector, the class doesn't use regular expressions at all.
Upvotes: 0
Reputation: 1166
Thanks Reflector... forgot you were still free!
Reflected the System.Net.Mail.MailAddress...
Found that it used a void ParseValue(string address)
and void GetParts(string address)
methods to primary check the mail address format.
//Edited
Surprised, no RegEx was involved!
Upvotes: 1
Reputation: 51461
No it does not use a RegEx, but rather a complicated process that would take way too long to explain here. How do I know? I looked at the implementation using the .NET Reflector. And so can you :D
http://www.red-gate.com/products/reflector/ (it's free)
Upvotes: 3