Re: RegularExpressionValidator expression help
- From: "Alexey Smirnov" <alexey.smirnov@xxxxxxxxx>
- Date: 19 Feb 2007 14:56:37 -0800
On Feb 19, 10:53 pm, "John" <J...@xxxxxxxxxxxxxxxxxxxx> wrote:
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
"Alexey Smirnov" <alexey.smir...@xxxxxxxxx> wrote in message
news:1171913472.788898.188800@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 19, 8:00 pm, "John" <J...@xxxxxxxxxxxxxxxxxxxx> wrote:
Thanks Alexey. No 1 are the UK post codes.
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
Check this article
http://www.answers.com/topic/uk-postcodes- Hide quoted text -
- 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.
.
- References:
- RegularExpressionValidator expression help
- From: John
- Re: RegularExpressionValidator expression help
- From: Alexey Smirnov
- Re: RegularExpressionValidator expression help
- From: John
- Re: RegularExpressionValidator expression help
- From: Alexey Smirnov
- Re: RegularExpressionValidator expression help
- From: John
- RegularExpressionValidator expression help
- Prev by Date: Re: reset button and validation controls
- Next by Date: Re: where to define variable for whoel application?
- Previous by thread: Re: RegularExpressionValidator expression help
- Next by thread: Re: Binding custom object to formview
- Index(es):
Relevant Pages
|