I want to validate input (number with decimal optional) in c# with regular expression with following conditions
- Max length of should be 4
- only positive numbers
- decimal is optional Eg valid case :
- 1
- 12
- 123
- 1234
- 1.23
- 12.3
- 0
Invalid cases :
- All -ive numbers
- Length exceeds 4 including decimal(.)
I have created following expression which is working fine but only problem is I am not able to restrict it to 4 max length
here is my regular expression :
^[\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$