Let me share with you the 2018 mobile phone number regular expression verification method, the specific content is as follows:
/** * Determine whether the string meets the mobile phone number format * Move number segment: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188 * Unicom number segment: 130,131,132,145,155,156,170,171,175,176,185,186 * Electric signal segment: 133,149,153,170,173,177,180,181,189 * @param str * @return The string to be detected */
public static boolean isMobileNO(String mobileNums) { /** * Determine whether the string meets the mobile phone number format * Move number segment: 134,135,136,137,138,139,147,150,151,152,157,158,159,170,178,182,183,184,187,188 * Unicom number segment: 130,131,132,145,155,156,170,171,175,176,185,186 * Electric signal segment: 133,149,153,170,173,177,180,181,189 * @param str * @return The string to be detected */ String telRegex = "^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\\d{8}$";// "[1]" means the first digit is the number 1, "[358]" means the second digit can be one of 3, 5, and 8, "\\d{9}" means that the number can be 0 to 9, and there are 9 digits. if ((mobileNums)) return false; else return (telRegex); }
”^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))\d{8}$" is actually very simple:
①The ten first three digits of 130-139 have been activated, and each of the last 8 digits is any number between 0-9;
②There are currently only three digits 145, 147, and 149 at the beginning of 14, and each of the 8 digits in the last 8 is any number between 0-9;
③The third digit starting with 15 except 154 can be taken at will, and each digit in the next 8 digits is any number between 0-9;
④The ten first three digits of 180-189 have been activated, and each of the last 8 digits is any number between 0-9;
⑤There are currently seven digits starting with 170, 171, 173, 175, 176, 177, and 178, and each of the next 8 digits is any number between 0-9;
These regular expressions are only judged on the front end. In actual development, these data will still be passed to the backend. The backend will judge whether the 11-digit number is a mobile phone number in the database. We write this to filter some of the most basic numbers and ensure that the number digits entered are 11 digits, and some 11-digit numbers that do not seem to be mobile phone numbers.
Summarize
The above is the latest Android 2018 regular expression verification method introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!