码迷,mamicode.com
首页 > Windows程序 > 详细

C# 常用格式判断

时间:2015-07-17 09:36:06      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 1         /// <summary>
 2         /// Verifies that a string is in valid e-mail format
 3         /// </summary>
 4         /// <param name="email">Email to verify</param>
 5         /// <returns>true if the string is a valid e-mail address and false if it‘s not</returns>
 6         public static bool IsValidEmail(string email)
 7         {
 8             if (String.IsNullOrEmpty(email))
 9                 return false;
10 
11             email = email.Trim();
12             var result = Regex.IsMatch(email, "^(?:[\\w\\!\\#\\$\\%\\&\\‘\\*\\+\\-\\/\\=\\?\\^\\`\\{\\|\\}\\~]+\\.)*[\\w\\!\\#\\$\\%\\&\\‘\\*\\+\\-\\/\\=\\?\\^\\`\\{\\|\\}\\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-](?!\\.)){0,61}[a-zA-Z0-9]?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\\[(?:(?:[01]?\\d{1,2}|2[0-4]\\d|25[0-5])\\.){3}(?:[01]?\\d{1,2}|2[0-4]\\d|25[0-5])\\]))$", RegexOptions.IgnoreCase);
13             return result;
14         }
Email邮件格式

 

C# 常用格式判断

标签:

原文地址:http://www.cnblogs.com/ziranquliu/p/4653425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!