Re: RegularExpressionValidator expression help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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-H­JKSTUW])
[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.

.



Relevant Pages

  • Re: Fastest way to search a string for the occurance of a word??
    ... but the OP's question was what's the "Fastest way to search a string ... in all the tests I did here, the Regex was by far superior. ... However, of course, if you've got new regular expressions all ... Sure - but just that extra Match object could be relevant if the search ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: regular expression help
    ... Basically because if you remove everything that is optional in the regex below you end up with an empty regex: ... So the regex engine will try to match on every character in the string: ... , comma doesn't match, but the nothingness in front of it does. ... A quote followed by any sequence of characters that is not a quote, ...
    (microsoft.public.dotnet.framework)
  • Re: Regex optimization
    ... I was hoping that someone with knowledge of the Regex engine could ... match per string for either Regex. ... reluctant modifier, may be slower .*?, +? ... Variable parts will try to capture as much as possible. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regex Capture problem
    ... "learned" my regex using a freeware utility that had slightly different ... was trying to capture instead of. ... I have used Regex utilities before, so I understand the concepts of text ... Function RESub(str As String, SrchFor As String, ReplWith As String) As String ...
    (microsoft.public.excel.programming)
  • Re: Trim a multiple line message to a single line
    ... You can do this quite easily with either a regex or a simple function I'll try to demonstrate both: ... private string LayoutInput ... Could you send a sample file with two of these data blocks f what ...
    (microsoft.public.dotnet.languages.csharp)