A regular expression that validates and matches UK National Insurance Number (NIN).
NIN is a 9-digit unique identification number issued by the UK Government to residents of the UK. It captures the nation-state identity of the people of the UK and its territories. A NIN is required to open bank accounts and file income returns, apply for marriage licenses, conduct commercial transactions, open a store and register your vehicle.
This regex is specific to UK National Insurance Number (NIN) only. It checks for validity and also matches the input, thus can be used to verify whether a number provided by the user exists or not in the database.
/^(?!BG)(?!GB)(?!NK)(?!KN)(?!TN)(?!NT)(?!ZZ)(?:[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z])(?:\s*\d\s*){6}([A-D]|\s)$/g
Matches:
- AA123456C
- BB 11 22 33 B
- CC 11 22 33 D
Non-matches:
- DD123456A
- FF 11 22 33 B
- VV112233Z
See Also:
- Social Insurance Number (SIN Canada) Regular Expression
- Regex To Validate Telephone Number In UK
- UK Bank Sort Code Regular Expression
- Regular Expression To Valid UK Vehicle Registration Numbers
- Regular Expression To Match US/UK/CA Zip (Postal) Codes