public bool ValidateEmailFormat(string email)
{
try
{
System.Text.RegularExpressions.Regex regObj = new System.Text.RegularExpressions.Regex(@"/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*");
System.Text.RegularExpressions.Match matchObj = regObj.Match(email);
return matchObj.Success;
}
catch{return false;}
}
{
try
{
System.Text.RegularExpressions.Regex regObj = new System.Text.RegularExpressions.Regex(@"/w+([-+.]/w+)*@/w+([-.]/w+)*/./w+([-.]/w+)*");
System.Text.RegularExpressions.Match matchObj = regObj.Match(email);
return matchObj.Success;
}
catch{return false;}
}
博客给出了一个验证电子邮件格式的代码。定义了一个名为 ValidateEmailFormat 的方法,使用正则表达式匹配输入的电子邮件字符串,若匹配成功则返回 true,若出现异常则返回 false。
2855

被折叠的 条评论
为什么被折叠?



