正则使用
@Test
public void PatternTest() {
String mobile = "15011xxx22";
String pattern = "^(?=\\d{11}$)^1(?:3\\d|4[57]|5[^4\\D]|66|7[^249\\D]|8\\d|9[89])\\d{8}$";
boolean isMatch = Pattern.matches(pattern, mobile);
System.out.println("这个手机号为"+isMatch);
}
常用正则手机号判断
String pattern = "^(?=\\d{11}$)^1(?:3\\d|4[57]|5[^4\\D]|66|7[^249\\D]|8\\d|9[89])\\d{8}$"; 详见打开链接