piighost/es-dni-nie

Both Spanish personal identifiers in one pattern: the DNI, eight digits and a check letter, and the NIE, a leading X, Y or Z then seven digits and a check letter, with the hyphen often typed between number and letter left optional. The trailing class is exactly the twenty-three letter check alphabet, so I, O and U, which are never issued, are refused, and that removes about an eighth of the random false positives for free. An eight digit order number followed by a letter still matches. No collision: the existing us-passport is letter first and cannot overlap a letter last DNI.

Label: ES_DNI_NIE

Pattern

\b(?:\d{8}|[XYZ]\d{7})-?[A-HJ-NP-TV-Z]\b

Must be caught

Must be left alone

Tags: es, government-id, identity

Download the detector as TOML