can someone help me with my regular expression. I have already read many pages about regular expressions, but I just don't seem to get it in general.
The function below need to check if the control_string is positive, contains only numbers and needs tot start with 1-9 followed by zero or more other numbers.
So "1", "12", "230" are ok, but "01", "a", "23c" etc. are wrong (all without the quotes of course). At the moment it works for the most part, but it also accepts "01".
What am I doing wrong?
I hope you guys can help me out.
public static Boolean checkIt(string control_string)
Regex objNotNaturalPattern = new Regex("[^0-9]");
Regex objNaturalPattern = new Regex("[1-9][0-9]*");
return (!objNotNaturalPattern.IsMatch(control_string) && objNaturalPattern.IsMatch(control_string));