最近发现各大手机运营商又增加了新的号码段,在项目中的判断手机号码的正则表达不能用了,自己搜集了一下,新写了一个正则表达式,希望有帮助。
- 匹配手机号码的正则表达式:
^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$
/**
* 判断是否是手机号
* @param mobile
* @return boolean
*/
public static boolean isMobile(String mobile) {
String regex = "^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$";
Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(mobile);
return m.matches();
}
目前已支持的匹配号段
中国电信号段
133、149、153、173、177、180、181、189、199
中国联通号段
130、131、132、145、155、156、166、175、176、185、186
中国移动号段
134(0-8)、135、136、137、138、139、147、150、151、152、157、158、159、178、182、183、184、187、188、198
其他号段
14号段以前为上网卡专属号段,如中国联通的是145,中国移动的是147等等。
虚拟运营商
电信:1700、1701、1702
移动:1703、1705、1706
联通:1704、1707、1708、1709、171
附加一个在线测试正则表达式的地址:
http://tool.oschina.net/regex/
----本文转载自 :https://blog.csdn.net/github_36344730/article/details/79757676?utm_source=copy