标签:
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 }
标签:
原文地址:http://www.cnblogs.com/ziranquliu/p/4653425.html