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.