Verifying the phone number in your app is a common feature, and the phone number includes a phone number and a landline number. Write this regular expression today for a relatively long time, recorded here, for later use. One of the basic assumptions in this article: mobile phone numbers are 11-bit, landline numbers plus the area code is also 11-bit .
First, the rule of the landline code: Click on the Popular science. This is a blog post of NetEase, simply say the landline code is the product of history, I also see here to know a probably. Summed up I think it can be summed up in this way: Beijing area code 010, the back 8 digits; Other regions to 0 as the first place, 2~9 position, the rest is 0~9. So the sum up of the regular formula should be this:
(010\d{8}) | (0[2-9]\d{9})
and mobile phone number is not the same, the number of mobile phone number segment is not fixed, the current can be consulted on the operation of the Business name section see:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/53/47/wKioL1RlubHyBnMYAADFoECuQHo018.jpg "title=" Qq20141114161110.jpg "alt=" Wkiol1rlubhybnmyaadfoecuqho018.jpg "/>
Observation can be found that the 13* series is complete, and the beginning of 14 only 145, 1472 number of paragraphs, 15 and 18th in addition to missing 154, 184 is also complete. So the regular expressions are listed as follows:
(13\d{9}) | (14[57]\d{8}) | (15[0-35-9]\d{8}) | (18[0-35-9]\d{8})
The two are linked together to verify the phone and landline numbers, as follows:
(010\d{8}) | (0[2-9]\d{9}) | (13\d{9}) | (14[57]\d{8}) | (15[0-35-9]\d{8}) | (18[0-35-9]\d{8})
The above formula is tested by the online test tool,
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/4A/wKiom1RlvgHhWfqxAADCzjD2j1k324.jpg "title=" Qq20141114161453.jpg "alt=" Wkiom1rlvghhwfqxaadczjd2j1k324.jpg "/>
This expression is written a bit long, if there is more concise wording also please enlighten me, thank you!
This article is from the "Flying Cat" blog, be sure to keep this source http://flyingcat2013.blog.51cto.com/7061638/1576568
Regular expressions for verifying phone and landline numbers