K
Kristof Van Praet
Hello group,
I have the following problem with a regular expression:
I try to check whether or not a string exists of exactly two numbers (e.g.
12). Therefore, I have the following regular expression "[0-9]{2}".
I try to use this in .NET (1.1 SP1) with the System.Text.RegularExpressions
class like this:
Console.WriteLine(regex.IsMatch("1").ToString());
Console.WriteLine(regex.IsMatch("10").ToString());
Console.WriteLine(regex.IsMatch("100").ToString());
This gives me the following results:
False
True
True
This is not what I expected. I expected:
False
True
False
When I tried "[0-9]{2,2}" I also got
False
True
True
Can anyone tell me what is wrong with my regular expression?
Thx,
Kristof
I have the following problem with a regular expression:
I try to check whether or not a string exists of exactly two numbers (e.g.
12). Therefore, I have the following regular expression "[0-9]{2}".
I try to use this in .NET (1.1 SP1) with the System.Text.RegularExpressions
class like this:
Console.WriteLine(regex.IsMatch("1").ToString());
Console.WriteLine(regex.IsMatch("10").ToString());
Console.WriteLine(regex.IsMatch("100").ToString());
This gives me the following results:
False
True
True
This is not what I expected. I expected:
False
True
False
When I tried "[0-9]{2,2}" I also got
False
True
True
Can anyone tell me what is wrong with my regular expression?
Thx,
Kristof