I have an application that uses the following Regex to validate UK post Codes.
(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})
If I understand this regex correctly Post codes allowed should be either this post code:
GIR 0AA
Or then we can compose the first part of the post code as follows:
Either
ANN (where A is any letter except for QVX and N is any number)
or
ABNN (where A is any letter except for QVX, B any letter except for IJZ and N is any number)
or
ANC (where A is any letter except for QVX, N is any number and C is any letter from A-H and then J, K, S, T, U, W)
or
ABND (where A is any letter except for QVX, B any letter except for IJZ, N is any number and D can be any of ABEHMNPRVWXY)
The second part of the post code is
NEE (where N is any number and E is any letter except for any of CIKMOV)
This is my understanding of the above regex.
What I can't understand is why it is allowing aaa1 1aa or aaa11 1aa
Any ideas?