最新手机号校验
java 后台校 验手机号用的是非常多, 自己平时都是在问度娘,但是那些校验的号码都是老号, 移动和联通都电信都会更新, 所以自己根据查号吧提供的最新的号码段做校验,下面是自己的写的正则
package com.macro.mall.util;
import org.apache.commons.lang3.StringUtils;
import java.util.regex.Pattern;
/**
* @Desc 用于后台手机号的验证工具类
* @Date 2019/3/12 19:21
* @Author cui_yl
*/
public class ValidateUtils {
private static final String REGEX_MOBILE ="((\\+86|0086)?\\s*)((134[0-8]\\d{7})|(((13([0-3]|[5-9]))|(14[5-9])|15([0-3]|[5-9])|(16(2|[5-7]))|17([0-3]|[5-8])|18[0-9]|19(1|[8-9]))\\d{8})|(14(0|1|4)0\\d{7})|(1740([0-5]|[6-9]|[10-12])\\d{7}))";
/**
* 判断是否是手机号
* @param tel 手机号
* @return boolean true:是 false:否
*/
public static boolean isMobile(String tel) {
if (StringUtils.isEmpty(tel)){ return false;}
return Pattern.matches(REGEX_MOBILE, tel);
}
}
测试