用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

邮箱验证、手机验证

2015-09-09 作者: 中哥举报

[java]代码库

/**
 *
 * TODO 方法作用:邮箱验证
 *
 * @param email
 * @return
 * @Author: 刘泽中
 * @Date: 2015-5-8 上午09:55:16
 */
public static boolean checkEmail(String email) {
    boolean result = false;
    try {
        Pattern regex = Pattern.compile("^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
        Matcher matcher = regex.matcher(email);
        result = matcher.matches();
    } catch (Exception e) {
        result = false;
    }
    return result;
}
 
/**
 *
 * TODO 方法作用:电话验证
 *
 * @param mobile
 * @Author: 刘泽中
 */
public static boolean checkMobileFormat(String mobile) {
    boolean result = false;
    try {
        String check = "^(((13[0-9])|(15([0-3]|[5-9]))|(17([0-9]))|(18[0,5-9]))\\d{8})$";
        Pattern regex = Pattern.compile(check);
        Matcher matcher = regex.matcher(mobile);
        result = matcher.matches();
    } catch (Exception e) {
        result = false;
    }
    return result;
}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...