Pattern library/China ID card regex
China ID card regex
Structural match for 18-char IDs ending in digit or X. Does not verify the checksum digit.
Expression
/(?<!\d)[1-9]\d{5}(?:19|20)\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\d|3[01])\d{3}[\dXx](?!\d)/gHow to read it
[1-9]\d{5}Region code(?<!\d)…(?!\d)Not part of a longer digit run
Sample test
2 match(es)IDs: 11010119900307891X, 44030119851212001X. Invalid: 123456, 1101011990030789123.
Starter prompt: match China 18-digit national ID numbers