竟然发现,没分给了~~public static bool isEmail1(string emailString)
{
return Regex.IsMatch(emailString, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
}public static bool IsEmail2(string strEmail)
{
return Regex.IsMatch(strEmail, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}public static bool IsEmail3(string strEmail)
{
return Regex.IsMatch(strEmail, @"^@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}这3方法有何区别?
{
return Regex.IsMatch(emailString, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$");
}public static bool IsEmail2(string strEmail)
{
return Regex.IsMatch(strEmail, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}public static bool IsEmail3(string strEmail)
{
return Regex.IsMatch(strEmail, @"^@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}这3方法有何区别?
可以比较好的验证整个email,像邮件-ab.-bx555x.@[13.13.13.13],[email protected]这样的email验证不通过,邮件[email protected],[email protected]可以通过。
正则二:
-ab.-bx555x.@[13.13.13.13],[email protected]可以验证通过。[email protected],[email protected]也能通过.
正则三:
可以验证通过@[13.13.13.13]和@-abc。11总结:
正则一是验证一般的email用的,正则二的具体用途没碰到过,反正它可以验证[13.11.11.11]这种ip为后缀的email,正则三就是专门验证这个后缀的