UK National Insurance Number (NIN) Regular Expression

Category: Numbers

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:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.