Regular Expression to validate UK National Insurance Number

后端 未结 8 1230
谎友^
谎友^ 2020-12-24 03:05

I have the following regular expression which validates the British National Insurance Number

^([a-zA-Z]){2}( )?([0-9]){2}( )?([0-9]){2}( )?([0-9]){2}( )?([         


        
8条回答
  •  Happy的楠姐
    2020-12-24 03:27

    I found a link to the government xml document which contains the regular expression for validating national insurance which was:

    [A-CEGHJ-NOPR-TW-Z]{2}[0-9]{6}[ABCD\s]{1}

    I've done some testing on regex online and seems to work well and in only 4 steps.

    https://web.archive.org/web/20121026141031/http://webarchive.nationalarchives.gov.uk/+/http://www.cabinetoffice.gov.uk/media/291296/CitizenIdentificationTypes-v1-4.xml

提交回复
热议问题