美文网首页
电话邮箱校验工具类

电话邮箱校验工具类

作者: 赵镇 | 来源:发表于2020-12-21 22:20 被阅读0次
public class MobileEmailUtils {

    public static boolean checkMobileIsOk(String mobile) {
        String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(mobile);
        boolean isMatch = m.matches();
        return isMatch;
    }

    public static boolean checkEmailIsOk(String email) {
        boolean isMatch = true;
        if (!email.matches("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+")) {
            isMatch = false;
        }
        return isMatch;
    }
}

针对这个做针对性的正则修改比较简单

欢迎关注和点赞

相关文章

网友评论

      本文标题:电话邮箱校验工具类

      本文链接:https://www.haomeiwen.com/subject/azndnktx.html