Bjarni

Bjarni

  • NA
  • 3
  • 2.2k

trouble with C# and regular expressions

Feb 21 2007 5:59 AM
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)