I encounter something in regular expression with validation numbers, asp.net. I want to limit mamimum total digit counts are 5. And decimal numbers are 2 positions for maximum, cannot exceed 2 digits, but need to valid total word count is not large than 5.
Eg. Valid Numbers 12345 1234.5 123.45 0.12 Invalid Numbers 1.2345 ( decimal digit is 4. and validation fail because decimal digits are more than 2 ) 1.234 and 12.345 ( decimal digit is 3. and validation fail because decimal digits are more than 2 ) I've tried:
String regnumeric = @"^([0-9]{0,5})(\.[0-9]{0,5})?$"; But I've observed it doesn't match with what I need. It just check count before and count after decimal point can be zero to 5. It doesn't include checking total number of digits. I have no idea how to do it
.12345a valid number? Or does that count as0.12345?