Re: Regex code not working
I just did a search on RegEx Lib and they have posted a Regular Expression for validating UK National Identification numbers here:
http://regexlib.com/REDetails.aspx?regexp_id=527
Re: Regex code not working
Quote:
Originally Posted by
happyme
Hi,
I have written a short piece of code to validate a UK NI number.
The format is 2 upper case letters, followed by 6 digits followed by A,B, C or D
eg AB123456A is OK
...
Code:
Dim NIr As Regex
Dim match As Boolean
NIr = New Regex("^[A-Z]^2[0-9]^6[A,B,C,D]")
match = NIr.IsMatch(NI_Num(count))
match is always false. Any suggestions where I'm going wrong?
Tia
H
"^" means "begining of line or string".
Try Expresso software to understand and debug regular expressions.
By the way, you probably want this:
Code:
"^[A-Z]{2}[0-9]{6}[A,B,C,D]"