Android 2018 latest mobile phone number verification regular expression method, android2018

Source: Internet
Author: User

Android 2018 latest mobile phone number verification regular expression method, android2018

The following is a regular expression Verification Method for mobile phone number 2018. The details are as follows:

/*** Determine whether the string conforms to the mobile phone number format * mobile 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 * Telecom number 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 conforms to the mobile phone number format * mobile 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 * Telecom number segment: 133,149,153,170,173,177,180,181,189 * @ param str * @ return the String to be detected */String telRegex = "^ (13 [0-9]) | (14 [, 9]) | (15 [^ 4]) | (18 [0-9]) | (17 [, 5, 8]) \ d {8} $ "; // "[1]" stands for 1st The digit is 1, and "[358]" indicates that the second digit can be one of 3, 5, and 8. "\ d {9}" indicates that the latter digit can be 0 ~ 9 digits, 9 digits. If (TextUtils. isEmpty (mobileNums) return false; else return mobileNums. matches (telRegex );}

"^ (13 [0-9]) | (14 [5, 7, 9]) | (15 [^ 4]) | (18 [0-9]) | (17 [, 8]) \ d {8} $ "is actually very simple:

① 130-139 all the top three of the ten have been activated, and each of the last eight digits is an arbitrary number between 0-9;

② Currently, there are only three digits starting with 145, 147, and 149. Each digit of the last eight digits is an arbitrary number between 0-9;

③ The Third digit except 154 at the beginning of 15 can be obtained at will, and each digit of the last eight digits is any number between 0-9;

④ 180-189, the first three of the ten are all activated, and each of the last eight 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 following eight digits is an arbitrary number between 0 and 9;

These regular expressions are only used in front-end judgment. In actual development, the data will still be transmitted to the background, and the background will judge in the database whether the 11-digit number is a mobile phone number, we write this statement to filter out some of the most basic numbers, ensure that the entered number is 11 bits, and there are some 11 bits that do not look like mobile phone numbers

Summary

The above section describes the regular expression verification method for the latest Android 2018 mobile phone number. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.