The expression they have given;
^(GIR
0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HIK-Y][0-9](|[0-9]|[ABEHMNPRVWXY])|[0-9][A-HJKSTUW])
[0-9][ABD-HJLNP-UW-Z]{2})$
Is not accepted by the validator. Sorry I am a little weak on regular
expressions.
Thanks
Regards
ok, it means you could use more precise expression
a) because A-Z, not a-z
b) format has some defined logic such as AA9 9AA or AA9A 9AA
- Show quoted text -
..NET has own syntax, I'm not sure but from the first look the problem
is somewhere with OR (|||)
Take a look at first expression
[A-Z]{1,2}[0-9R][0-9A-Z]?\s[0-9][A-Z]{2}
("\s" means a single space, and should be used in .NET)
This expression is working and short enough. If you want to accept
address of Santa
Do this
[A-Z]{1,2}[0-9R][0-9A-Z]?\s[0-9][A-Z]{2}|SAN\sTA1
By adding carat (^) at the beginning and dollar sign ($) at the end
the regex will only match if it contains the postal code
Regarding complexity: I don't think that this is neccessary to incl.,
for example, all used letters, or something like this. Anyhow there is
no way to check by regex if given postal code is related to given
city, or given area. In my opinion it should just check if the size of
the string is correct and string has proper format, e.g. space in the
middle and this will be enough.