RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find UK National Insurance Number
Expression
^((A[ABEHKLMPRSTWXYZ])|(B[ABEHKLMT])|(C[ABEHKLR])|(E[ABEHKLMPRSTWXYZ])|(GY)|(H[ABEHKLMPRSTWXYZ])|(J[ABCEGHJKLMNPRSTWXYZ])|(K[ABEHKLMPRSTWXYZ])|(L[ABEHKLMPRSTWXYZ])|(M[AWX])|(N[ABEHLMPRSWXYZ])|(O[ABEHKLMPRSX])|(P[ABCEGHJLMNPRSTWXY])|(R[ABEHKMPRSTWXYZ])|(S[ABCGHJKLMNPRSTWXYZ])|(T[ABEHKLMPRSTWXYZ])|(W[ABEKLMP])|(Y[ABEHKLMPRSTWXYZ])|(Z[ABEHKLMPRSTWXY]))\d{6}([A-D]|\s)$
Description
UK National Insurance (NI) Number, updated 14 Dec 2005 and current for 2006.
Matches
NS123456A | AA555555A | ZY654321
Non-Matches
QB123456A | DD123456D | MB654321X
Author Rating: Not yet rated. Amos Hurd
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: nino for an italian citizen
Name: leo
Date: 5/10/2011 3:50:46 PM
Comment:
hi there I d like to ask if somebody knows if the job center issues a temporary nino number or something that allows you to work while the permanent one is being processed because I want to go to london and get a job there but how I could do that if I have to wait 8 weeks I am italian but cant afford paying the rent for 2 months without getting any income what should I do stay there 8 weeks arms crossed waiting I read somewhere that you could ask at the job center for soe temporary number


Title: Terminating in a space
Name: I.Canoe
Date: 2/23/2010 4:23:35 AM
Comment:
An alternative would be as follows: /^(G[ACEGHJ-NPR-TW-Z]|B[A-CEHJ-NPR-TW-Z]|N[A-CEGHJL-NPR-SW-Z]|K[A-CEGHJ-MPR-TW-Z]|T[A-CEGHJ-MPR-TW-Z]|Z[A-CEGHJ-NPR-TW-Y])[0-9]{6}[A-DFM]{0,1}$/


Title: Terminating in a space
Name: I.Canoe
Date: 2/23/2010 4:22:45 AM
Comment:
Excellent, thanks you. However, given that a NINO may end with a space, but that the owner of such a NINO will not be aware of this, the expression might be better written to terminate: \d{6}[A-D]{0,1}$/


Title: Terminating in a space
Name: I.Canoe
Date: 2/23/2010 4:07:08 AM
Comment:
Excellent, thanks you. However, given that a NINO may end with a space, but that the owner of such a NINO will not be aware of this, the expression might be better written to terminate: \d{6}[A-D]{0,1}$/


Title: Terminating in a space
Name: I.Canoe
Date: 2/23/2010 4:06:47 AM
Comment:
Excellent, thanks you. However, given that a NINO may end with a space, but that the owner of such a NINO will not be aware of this, the expression might be better written to terminate: \d{6}[A-D]{0,1}$/


Title: Feedback
Name: Richie Hare
Date: 10/25/2007 5:19:59 AM
Comment:
Outstanding! The most accurate pattern I have been seen! Many thanks to you, Mr Hurd.


Title: question
Name: Richard Abbey
Date: 8/8/2007 7:33:31 PM
Comment:
This is the best NINO expression I've seen so far. Couple of questions... What would be the best way to support mixed case entry using this expression? I know they *should* be capitalised, but I'd like to cut my users some slack. I can do the capitalisation later. Is this a regexp noob question? Other question is about NC, NK, NO, ZZ, XX and QQ prefixes. These appeared to be valid during 2004-2005. Anyone confirm this? here's my source for this question... http://www.hmrc.gov.uk/ebu/supp-ni-2003-2.pdf


Title: Re: Source of Info
Name: Dave
Date: 12/22/2005 7:23:53 AM
Comment:
Amos, Thankyou very much for the link. With regard to my solution, it was designed only to validate data already stored in a third party client database. The data will be used to reference against Job Centre Data at which point all the data will be extracted and converted to upper case. In short it is only used to check the data and display a warning to the user, but thankyou for pointing that out. Dave


Title: Source of Info
Name: Amos Hurd
Date: 12/22/2005 4:50:22 AM
Comment:
Thanks again for the feedback. I always take the Revenue and Customs specification as being the most likely to be valid (they "own" the spec after all), and I did notice the GovTalk expression would be highly unreliable, which makes me wary of their interpretation of the format rules. http://www.hmrc.gov.uk/ebu/ebu_paye_ts.htm Using the above URI and Near the bottom of the page, there are several guidance notes for software developers, some of which deal specifically with NI. There is a supplement for December 2005 which is the most recent information I have found regarding the prefixes. Regards, Amos PS. As an aside, one thing about your solution, as far as I gather only uppercase characters should be used, so any lowercase characters should be converted prior to validation with a regular expression. Just my 2p worth. :)


Title: Very Interesting! pt2
Name: Dave
Date: 12/21/2005 10:45:52 AM
Comment:
One thing I did do was allow the last character to be blank (as well as space) since a user entering the info may assume a space to be a null character and not enter it. The one I wrote is: .Pattern = "^([A-CEGHJ-PR-TW-Z]{1}|[a-ceghj-pr-tw-z]{1})([A-CEGHJ-NPR-TW-Z]{1}|[a-ceghj-npr-tw-z]{1})\d{6}([ABCD\s]{1}|[abcd\s]{1}|$)$" 'Check Frist Two Characters aren't combinations of GB,NK,TN,ZZ .Pattern = "(^GB)|(^BG)|(^NK)|(^KN)|(^TN)|(^NT)|(^ZZ)+" Dave


Title: Very Interesting!
Name: Dave
Date: 12/21/2005 10:45:03 AM
Comment:
Very interesting what you have done .. in particular the '|(M[AWX])|' part. This does not appear to be fitting with the Spec from the Cabinet Office. Is this info from some other source? It's also interesting that their own XML RegExp appears to be incorrect! Their RegExp is: <xsd:pattern value="[A-CEGHJ-NOPR-TW-Z]{2}[0-9]{6}[ABCD\s]{1}"/> This would allow the second character to be O which according to their spec is disallowed. ... --- 1. Must be 9 characters. 2. First 2 characters must be alpha. 3. Next 6 characters must be numeric. 4. Final character can be A, B, C, D or space. 5. First character must not be D,F,I,Q,U or V 6. Second characters must not be D, F, I, O, Q, U or V. 7. First 2 characters must not be combinations of GB, NK, TN or ZZ (the term combinations covers both GB and BG etc.) ---- I wrote a two stage test approach for my asp app but that may also be incorrect if you have additional info??? One thing I did do was allow the last character t


Title: Updated for 2006
Name: Amos Hurd
Date: 12/14/2005 12:33:45 PM
Comment:
I have updated the expression now for what seems to be current for 2006 with the introduction of several prefixes and the removal of all temporary suffixes.


Title: Thanks for the feedback
Name: Amos Hurd
Date: 12/14/2005 11:31:24 AM
Comment:
Thanks, I'm going to look into this again, as by now the valid prefix combinations will have changed, in addition to the removal of all temporary suffix characters.


Title: Temporary Numbers Not Valid
Name: Amos Hurd
Date: 7/12/2005 10:24:35 AM
Comment:
Further to the previous feedback, I checked up on the temporary number situation and can confirm that TN is no longer a valid prefix. The following document can be found on the HM Revenue and Customs web site; the section applicable in this case is on page 3, paragraph 1.3. http://www.hmrc.gov.uk/ebu/supp-ni-2003_05-06.pdf Thanks again. Regards, Amos


Title: Thanks for the feedback
Name: Amos Hurd
Date: 7/8/2005 2:35:42 AM
Comment:
Thank you for the feedback. I understood that these codes were no longer in accepted general use and were not applicable for the financial year I mentioned. I'll re-cheak my souces and modify accordingly if they are still valid. Regards, Amos


Title: Very useful - but what about temporary numbers?
Name: Patrick
Date: 7/7/2005 7:37:27 AM
Comment:
This is an excellent tool - but it doesn't seem to cater for temporary numbers issued to foreign nationals that are (or used to be) in the format TNDDMMYYM or TNDDMMYYF, where DDMMYY is the date of birth of the person with the temporary number.


Copyright © 2001-2014, RegexAdvice.com | ASP.NET Tutorials