Regular expressions for verifying phone and landline numbers

Source: Internet
Author: User

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

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.