普通方法验证 邮箱正确性
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
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
相关文章推荐
- mysql支持的数据类型简介
- C++的chrono、ratio和ctime等头文件
- Java - 认识 JDBC
- 直接跳转到appStore
- .**信息安全系统设计基础第十二周学习总结
- 大话设计模式之面向对象基础篇(三)
- python之Flask初体验
- linux 系统11步yum安装MySQL数据库
- oracle 11g创建与管理用户
- 单例模式
- js小时钟
- Android AutoLayout全新的适配方式 堪称适配终结者
- OpenCV中debug与release的问题
- 1.交通聚类:编辑距离 (Levenshtein距离)Java实现
- iOS中的#import和class区别
- 南大软院大神养成计划第十四天
- 快速排序
- Android 开源框架Universal-Image-Loader完全解析(三)---源代码解读
- 企业汇报系统细节追加(三)
- 计算机技术领域当前的主流技术及其社会需求调查报告