Verify Phone number format

Source: Internet
Author: User

Here is the regular expression that the mobile official pulled down:

Determine if a string is a mobile phone number
0 is the cell phone number 1 is not the 11 digit number 2nd code prefix is incorrect
Used to verify the number of digits in the mobile phone number and check whether the mobile phone is China Mobile phone number * *
Due to the presence of the portability of the network allows 3 operators of all the number of segments (pilot) */
China Mobile number segment: 134 (segment 0 to 8th) 135 136 137 138 139 147 150 151 152 157 158 159 178 182 183 184 187 188
China Unicom Number segment: 130 131 132 145 155 156 175 176 185 186
China Telecom Number segment: 133 153 177 180 181 189
Virtual Carrier number segment: 170

1 //determine if a string is a mobile phone number2 //0 is the cell phone number 1 is not the 11 digit number 2nd code prefix is incorrect3 /*used to verify the number of digits of the mobile phone number and to check if the mobile phone is mobile in China.*/4 /*full number of 3 operators (pilot) due to the presence of a portability switch*/5 //China Mobile number segment: 134 (segment 0 to 8th) 135 136 137 138 139 147 , 151 157 158 159 178 182 183 184 187 1886 //China Unicom number segment: 131 145 155 156 175 176 185 1867 //China Telecom Number segment: 133 153 177 181 1898 //Virtual operator number segment:9 functionIsphonenumber (phone) {Ten     varRV = 0; One  A     varMbphnom =/^ (13[4-9]) |^ (147) |^ (150) |^ (151) |^ (152) |^ (157) |^ (158) |^ (159) |^ (178) |^ (182) |^ (183) |^ (184) |^ (187) |^ (188) /; -     varMbphnou =/^ (130) |^ (131) |^ (132) |^ (145) |^ (155) |^ (156) |^ (175) |^ (176) |^ (185) |^ (186)/; -     varMbphnot =/^ (133) |^ (153) |^ (177) |^ (180) |^ (181) |^ (189)/; the     varMbphnov =/^ (170)/; -        -     varNUM11 =/^\d{11}$/;//11-digit number; -        +     if(NULL! = Phone && "! = Phone &&num11.exec (phone)) { -          +         if(Mbphnom.exec (phone) | | mbphnou.exec (phone) | | mbphnot.exec (phone) | |mbphnov.exec (phone)) { ARV = 0; at         } -         Else { -RV = 2; -         } -     } -     Else { inRV = 1; -     } to       +     returnRV; -}
View Code

Verify Phone number format

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.