我用正则验证邮件格式,验证方法如下:private bool verEmail(string email)
{
bool b = false;
string regexEmail ="\\s*([A-Za-z0-9_-]+(\\.\\w+)*@([\\w-]+\\.)+\\w{2,3})\\s*";
string regEx = "[`~!#$%^&*()+=|{}':;',\\[\\]<>/?~!#¥%……&*()——+|{}【】‘;:”“’。,、?]";
if (email.IndexOf("@") != email.LastIndexOf("@"))
        return false;
System.Text.RegularExpressions.RegexOptions options =((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace| System.Text.RegularExpressions.RegexOptions.Multiline)| System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regEmail = new System.Text.RegularExpressions.Regex(regexEmail, options);
System.Text.RegularExpressions.Regex regEx2 = new System.Text.RegularExpressions.Regex(regEx, options);
if (regEmail.IsMatch(email))
    b = true;
if (regEx2.IsMatch(email))
    b = false;
return b;
}上面的方法是完全正确的,第二个if是判断邮箱格式,第三个if是判断特殊字符,我在本地测试完全没有问题,但放在服务器上面就会发生有些合法邮箱也不能通过验证。
如:[email protected]。(-是半角的不是全角的)
诡异的是同一个邮箱,在本地没有任何问题,在服务器上就会通不过,更为诡异的是将这个邮箱更改任何一个字母就会通过验证,我只想问各位有碰到过这样的现象吗?
如何解决的?谢谢了。
太诡异了