您的位置:首页 > 其它

普通方法验证 邮箱正确性

2015-11-29 13:13 211 查看
普通方法验证Email正确性

public static boolean validateEmail(String text)
{
int atIndex = text.indexOf('@');
int dotLastIndex = text.lastIndexOf('.');

//必须含有@和.
if (atIndex < 0 || dotLastIndex < 0)
{
return false;
}
int textLen = text.length();

//不能以@或者.开始或者结束
if (atIndex == 0 || atIndex == textLen || dotLastIndex == 0
|| dotLastIndex == textLen)
{
return false;
}

//@要在最后一个.之前
if (atIndex > dotLastIndex)
{
return false;
}
return true;
}
@原著:http://blog.csdn.net/cownew/article/details/6477989
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: