用正则表达式验证手机号(兼容目前市面上100%手机号,但精确度特别低)

发文时间:2019.11.28

public static boolean isMobile(String str) {
    
    
	String regex1 = "^[1][3,4,5,6,7,8,9][0-9]{9}$";// 未来手机号可能出现100开头的,需要适当调整
	Pattern p = Pattern.compile(regex1);
	Matcher m = p.matcher(str);
	boolean isMatch = m.matches();
	return isMatch;
}
public static void main(String[] args) {
    
    
	String mobile = "13906203838";
    System.out.println(isMobile(mobile));
}

猜你喜欢

转载自blog.csdn.net/qq_36912167/article/details/103289328