正则表达式
"^(0|86|17951)?(13[0-9]|14[056789]|15[012356789]|16[6]|17[345678]|18[0-9]|19[89])[0-9]{8}$"
代码
public static boolean isPhone(String phone) {
Pattern pattern;
Matcher matcher;
String PHONE_PATTERN = "^(0|86|17951)?(13[0-9]|14[056789]|15[012356789]|16[6]|17[345678]|18[0-9]|19[89])[0-9]{8}$";
pattern = Pattern.compile(PHONE_PATTERN);
matcher = pattern.matcher(phone);
return matcher.matches();
}
号段
我在百度百科(手机号)中总结出来的,眼睛都快直了,如果有遗漏,欢迎补充
| 13 | 0 1 2 3 4 5 6 7 8 9 |
|---|---|
| 14 | 0 5 6 7 8 9 |
| 15 | 0 1 2 3 5 6 7 8 9 |
| 16 | 6 |
| 17 | 3 4 5 6 7 8 |
| 18 | 0 1 2 3 4 5 6 7 8 9 |
| 19 | 8 9 |
本文提供了一种使用正则表达式验证中国大陆手机号码的方法,并详细列出了所有有效的手机号段。
1万+

被折叠的 条评论
为什么被折叠?



