Home > Web Front-end > HTML Tutorial > Commonly used regular expressions: ID number verification regular expression_html/css_WEB-ITnose

Commonly used regular expressions: ID number verification regular expression_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:40:41
Original
1933 people have browsed it

I need a simple regular expression to verify the ID number. I checked a lot on the Internet, but there are problems. The main thing is that as long as it exceeds 15 digits, it can pass, so I checked the manual for a long time. I wrote the following formula, which can meet the simple requirements:
1, 15 digits or 18 digits. If it is 15 digits, they must all be numbers.
2. If it is 18 digits, the last digit can be a number or the letter Xx, and the rest must be numbers.

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

Thought from this expression:
1. Regular The expression must first pass the correct
2. The restriction is incorrect
3. It is not necessary to restrict certain rules, but the correct one must pass first.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template