Regular Expression for mobile phone number and license plate number in Android, and regular expression for android
The description of the number segment of the mobile phone number is reproduced from: Regular Expression of the domestic mobile phone number | accumulation of snails
The mobile phone name is GSM:It indicates that only China Unicom or China Mobile 2G segments (130, 131, 132, 134, 135, 136, 137, 138, 139, 145, 147, 150, 151, 152, 155, 156, 157, 158, 159, 182, 185, 186, 187, 188)
Mobile phone names include CDMA:It indicates that only China Telecom 2G segments (133, 153, 180, 181, 189) are supported)
The mobile phone name is WCDMA/GSM:China Unicom or China Mobile 2G segment is supported, and China Unicom 3G segment (130, 131, 132, 134, 135, 136, 137, 138, 139, 145, 147, 150, 151, 152, 155, 156, 157, 158, 159, 182,183185, 186, 187, 188), does not support mobile 3G services, does not support telecommunications cards.
Mobile phone name TD-SCDMA/GSM:China Unicom or China Mobile 2G segment is supported, china Mobile 3G segment (130, 131, 132, 134, 135, 136, 137, 138, 139, 145, 147, 150, 151, 152, 155, 156, 157, 158 ,), 159, 182,183, 185, 186, 187, 188), does not support China Unicom 3G business, does not support telecommunications cards.
The mobile phone name is CDMA/CDMA:China Telecom 2G segment and China Telecom 3G segment (133, 153, 180, 181, 189) are supported. mobile connection cards are not supported.
The mobile phone name is CDMA 2000/GSM (dual-mode Dual-Wait ):It indicates that one card supports China Telecom's 2G segment and China Telecom's 3G segment (133, 153, 180, 181, 189 ), the other card supports the speech and text message functions of China Mobile or China Unicom 2G segments.
Third-party carrier's 170 code segment
Supplement:China Unicom 4G 176, China Telecom 4G 177, and China Mobile 4G 178
The regular expression functions written based on these expressions are as follows:
1 public static boolean isMobileNO(String mobiles) {2 String telRegex = "13\\d{9}|14[57]\\d{8}|15[012356789]\\d{8}|18[01256789]\\d{8}|17[0678]\\d{8}";3 if (TextUtils.isEmpty(mobiles)) return false;4 else return mobiles.matches(telRegex);5 }
Where:
"13 \ d {9}" indicates that the first two digits are 1 and 3, followed by any 9 digits;
"14 [57] \ d {8}" indicates that the first two digits are 1 and 4, the third digit is 5 or 7, and the last two digits are any 8 digits;
And so on.
The Regular Expression of the license plate number has been available on the Internet and has not been changed:
1 public static boolean isCarnumberNO (String carnumber) {2/* 3 license plate number format: Chinese Character + A-Z + 5-digit A-Z or 0-94 (only including general license plate number, license plate numbers for coaches and some military vehicles are not included) 5 */6 String carnumRegex = "[\ u4e00-\ u9fa5] {1} [A-Z] {1} [A-Z_0-9] {5}"; 7 if (TextUtils. isEmpty (carnumber) return false; 8 else return carnumber. matches (carnumRegex); 9}
Of course, this regular expression has limitations. For example, the first character can only be Chinese characters, but only 34 Chinese characters can be abbreviated. The license plate number does not contain letters I and O, which prevents confusion with 1 and 0; some license plates cannot be distinguished.