Match the 18-bit ID number and the regular expression is as follows:
/^[1-9][0-9]{5} (19|20) [0-9]{2} ((01|03|05|07|08|10|12) (0[1-9]|[ 1-2][0-9]|31) | (04|06|09|11) (0[1-9]| [1-2] [0-9]|30] |02 (0[1-9]|[ 1-2][0-9])) [0-9]{3} ([0-9]|x| X) $/
Note: Now the ID number is already 18, there is no need to consider matching 15 bit.
18-digit ID Number: 6-digit area + 4-year + 4-month-day + 3-digit + 1-bit new generation number
Logic:
1) 6-digit area number: First non-0, after five digits. corresponding regular: [1-9][0-9]{5}
2) 4-digit year: 19 or 20 starts with the post two digits. Corresponding Regular: (19|20) [0-9]{2}
3) 4-Month Day:
i) Otsuki 31 days. Corresponding Regular: (01|03|05|07|08|10|12) (0[1-9]|[ 1-2][0-9]|31)
II) Xiao Yue for 30 days. Corresponding Regular: (04|06|09|11) (0[1-9]|[ 1-2][0-9]|30)
III) February 28 days or 29 days. corresponding Regular: 02 (0[1-9]|[ 1-2][0-9])
4) 3-digit number: three-digit number. corresponding regular: [0-9]{3}
5) 1-bit new generation number: number or X. corresponding Regular: ([0-9]|x| X
The perfect regular still has its drawbacks:
1) Unmatched leap year
2) does not match the presence of the first three-digit region number
The perfect 18-digit ID number for regular expressions