简体   繁体   English

RegEx由System.Net.Mail.MailAddress使用

[英]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.

相关问题 System.Net.Mail.MailAddress使用一个参数发送到多封电子邮件 - System.Net.Mail.MailAddress send to multiple emails with one parameter System.Net.Mail.MailAddress不允许Gmail GROUP联系人 - System.Net.Mail.MailAddress does not allow Gmail GROUP contact 无法将System.Net.Mail.MailAddress序列化为Json - Unable to serialize System.Net.Mail.MailAddress to Json 无法将类型“System.Net.Mail.MailAddress”隐式转换为“SendGrid.Helpers.Mail.EmailAddress” - Cannot implicitly convert type 'System.Net.Mail.MailAddress' to 'SendGrid.Helpers.Mail.EmailAddress' 使用System.Net.Mail.MailAddress或其他库指定.eml文件名 - Specify .eml file name using System.Net.Mail.MailAddress or other library 为什么 System.Net.Mail.MailAddress 构造函数在域部分解析带有斜杠“/”的电子邮件? - Why System.Net.Mail.MailAddress constructor parses email with slash "/" in domain part? System.Net.Mail.MailAddress验证电子邮件缺少TLD,认为我@有效 - System.Net.Mail.MailAddress validates email missing TLD, considers me@there valid MailAddress:在邮件头中找到无效字符 - MailAddress: An invalid character was found in the mail header MailAddress构造函数如何验证邮件地址 - How does the MailAddress constructor validate mail addresses c# 中 System.Net.Mail.Attachment.CreateAttachmentFromString 使用的默认编码是什么? - What is the default encoding used in System.Net.Mail.Attachment.CreateAttachmentFromString in c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM