A regular expression of the problem, the number of digits to write 1 can be matched on, write than 1 of the big match is not.
The regular is as follows:
$patten = '/^[1-9]\d{5}[1-2]\d{3} ((0\d) | ( 1[0-2]) (([0|1|2]\d) |3[0-1]) \d{4}$/';//This is the last 4.
If you change the last 4 to 1, you can match it and change it to 1.
This regular is to be used to match the ID card number, if any hero has the hope to be able to send out for reference ~ compatible with 15-bit and 18-bit ~
------Solution--------------------
1, the identity card number meaning:
Generation (now obsolete, no need to judge)
Area code (6-bit) birth year (2-digit) birth month (2-bit) birthday (2-bit) Shun (3-bit) total 15-bit
Second generation
Area code (6-bit) birth year (4-digit) birth month (2-bit) birthday (2-bit) Shun (3-bit) check digit (1-bit) total 18-bit
The check digit may be X
2, simple judgment, just determine whether the number of digits is correct
/^\D{15} (?: \ D{2}[\DX])? $/
3, the accurate determination (second generation) should use the check code generation algorithm. "ID Check code generation function" can be found on the Internet in various languages.
------Solution--------------------
Validateidnumber ( "22111111111234563 " );
The string, the value of the word is out of bounds
The original ID number should be a string.