[英]Is RegEx used by System.Net.Mail.MailAddress
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.
我有Google / Bing(ed)并扫描了前50个奇怪的结果,包括正则表达式信息文章和其他内容。
So finally i used the System.Net.Mail.MailAddress
class to validate my email address. 所以最后我使用
System.Net.Mail.MailAddress
类来验证我的电子邮件地址。 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? 那么,我如何继续获取MailAddress类正在使用的验证/ RegEx?
No it does not use a RegEx, but rather a complicated process that would take way too long to explain here. 不,它不使用RegEx,而是一个复杂的过程,需要花费太长时间才能在此处进行解释。 How do I know?
我怎么知道? I looked at the implementation using the .NET Reflector.
我看着使用.NET Reflector的实现。 And so can you :D
你也可以:D
http://www.red-gate.com/products/reflector/ (it's free) http://www.red-gate.com/products/reflector/ (免费)
Thanks Reflector... forgot you were still free! 谢谢Reflector ...忘了你还有空!
Reflected the System.Net.Mail.MailAddress... 反映了System.Net.Mail.MailAddress ...
Found that it used a void ParseValue(string address)
发现它使用了
void ParseValue(string address)
and void GetParts(string address)
methods to primary check the mail address format. 和
void GetParts(string address)
方法来主要检查邮件地址格式。
//Edited //编辑
Surprised, no RegEx was involved! 惊讶的是,没有涉及RegEx!
根据Reflector,该类根本不使用正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.