日期:2014-05-18 浏览次数:20472 次
function IsMail(mail) { var patrn = /^w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$/; return patrn.test(mail); }
------解决方案--------------------
/// <summary> /// Email 格式是否合法 /// </summary> /// <param name="StrEmail">源字符串</param> public static bool IsEmail(string StrEmail) { return Regex.IsMatch(StrEmail, @"^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"); }
------解决方案--------------------
string mailAddress = "adsfasfd";
try
{
MailAddress temp = new MailAddress(mailAddress);
}
catch(Execption ex)
{
//邮件地址不规范
}
------解决方案--------------------