就是这两个邮箱地址,正常使用,但被两种正则表达式都判断为不匹配
[email protected]
[email protected]
使用的验证函数: public static bool isEmail(string str_Email)
{
//string strRegex = @"^([\w-\.]+)+[a-zA-Z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
string strRegex = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
return Regex.IsMatch(str_Email, strRegex);
}
[email protected]
[email protected]
使用的验证函数: public static bool isEmail(string str_Email)
{
//string strRegex = @"^([\w-\.]+)+[a-zA-Z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
string strRegex = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
return Regex.IsMatch(str_Email, strRegex);
}
protected void Page_Load(object sender, EventArgs e)
{
string str = "[email protected]";
Response.Write(isEmail(str));
str = "[email protected]";
Response.Write(isEmail(str)); }
public static bool isEmail(string str_Email)
{
//string strRegex = @"^([\w-\.]+)+[a-zA-Z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
string strRegex = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
return Regex.IsMatch(str_Email, strRegex);
}
你把开头结尾的^$去掉再试试看。