W
wdudek
Hi,
I am horrible at regular expressions so I'm hoping this might be an easy
one for someone else. I need to perform a check that a string contains all
numbers and is between 1 and 9 characters long. I have the first part
working, but can't get the length check to work.
This is what I am using to perform the check to see if the string is all
numeric. ^[0-9]*$
However I can't get it to match anything when I have tried to check the
length as well. Also I need to do this in one expression, i.e. I can't make 1
call to check for numeric values and a second to check for length.
Thanks,
Bill
P.S. This is what I have been using to test this.
static void Main(string[] args)
{
//string input = "00767140001575333";
string input = "00767140";
Regex r = new Regex("^[0-9]*$");
bool result = r.IsMatch(input);
Console.WriteLine(result.ToString());
Console.WriteLine("hit a key");
Console.ReadKey();
}
I am horrible at regular expressions so I'm hoping this might be an easy
one for someone else. I need to perform a check that a string contains all
numbers and is between 1 and 9 characters long. I have the first part
working, but can't get the length check to work.
This is what I am using to perform the check to see if the string is all
numeric. ^[0-9]*$
However I can't get it to match anything when I have tried to check the
length as well. Also I need to do this in one expression, i.e. I can't make 1
call to check for numeric values and a second to check for length.
Thanks,
Bill
P.S. This is what I have been using to test this.
static void Main(string[] args)
{
//string input = "00767140001575333";
string input = "00767140";
Regex r = new Regex("^[0-9]*$");
bool result = r.IsMatch(input);
Console.WriteLine(result.ToString());
Console.WriteLine("hit a key");
Console.ReadKey();
}