M
Mark Rae
Hi,
I'm trying to construct a RegEx pattern which will validate a string so that
it can contain:
only the numerical characters from 0 to 9 i.e. no decimal points, negative
signs, exponentials etc
only the 26 letters of the standard Western alphabet in either upper or
lower case
spaces i.e. ASCII character 32
I seem to be doing OK with the first two criteria, but am having trouble
with the space character.
E.g. the following works perfectly:
Regex.IsMatch("ThisIsThe2ndString", @"[^0-9][^a-z][^A-Z]")
However, this doesn't work:
Regex.IsMatch("This Is The 2nd String", @"[^0-9][^a-z][^A-Z]")
I've tried various combinations of [\s] and [^\s] but with little success.
However, the following works, though I don't really understand why:
Regex.IsMatch("This is the 2nd string", @"[^0-9][^a-z][^A-Z]",
RegexOptions.IgnoreCase)
Any assistance gratefully received.
Mark
I'm trying to construct a RegEx pattern which will validate a string so that
it can contain:
only the numerical characters from 0 to 9 i.e. no decimal points, negative
signs, exponentials etc
only the 26 letters of the standard Western alphabet in either upper or
lower case
spaces i.e. ASCII character 32
I seem to be doing OK with the first two criteria, but am having trouble
with the space character.
E.g. the following works perfectly:
Regex.IsMatch("ThisIsThe2ndString", @"[^0-9][^a-z][^A-Z]")
However, this doesn't work:
Regex.IsMatch("This Is The 2nd String", @"[^0-9][^a-z][^A-Z]")
I've tried various combinations of [\s] and [^\s] but with little success.
However, the following works, though I don't really understand why:
Regex.IsMatch("This is the 2nd string", @"[^0-9][^a-z][^A-Z]",
RegexOptions.IgnoreCase)
Any assistance gratefully received.
Mark