最近發現各大手機運營商又增加了新的號碼段,在項目中的判斷手機號碼的正則表達不能用了,自己蒐集了一下,新寫了一個正則表達式,希望有幫助。
- 匹配手機號碼的正則表達式:
^((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