Common Regular Expressions: ID card number verification regular expressions,

Source: Internet
Author: User

Common Regular Expressions: ID card number verification regular expressions,

A simple regular expression used to verify the ID card number is required. I checked a lot from the Internet and found some problems. I checked the manual for half a day, the following formula can meet simple requirements:
1. 15 or 18 digits. If it is 15 digits, it must be all digits.
2. If it is 18 digits, the last digit may be a number or a letter Xx, and the remaining digits must be digits.

/^ (\ D {15} | \ d18 | ^ \ d {17} (\ d | X | x) $/

From this expression:
1. Regular Expressions must first pass the correct
2. The restriction is incorrect.
3. You do not need to limit one of these rules, but you must first pass the rule correctly.

Related Article

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.