2
Answers

trouble with C# and regular expressions

Bjarni

Bjarni

18y
2.2k
1
Hi, I am trying to use regular expression to check if a string is a number and I do not want leading zeros so "123" is legal but "0123" is not and I am using the following: Regex objNaturalPattern = new Regex("[1-9][0-9]*"); This works fine detecting if it is a number or alpha but it always gives me true for leading zeros, how can I make the zeros in front give me a false? Thanks
Answers (2)