I am trying to find a regular expression which accepts maximum 5 digits before decimal and maximum 2 digits after decimal. Decimal part is optional and should not accept if 0 is the only digit. But accepts if 0 is followed by other digits after or before decimal. For example:
Valid data are : 12345.12,123.12,0.12,00.12,1.2,0123.12
Invalid data are: 0,00,000,0000,00000
I have made an expression ^\d{0,5}(\.\d{1,2})?$"
but this does not work if the digit starts with 0.
00001.01
? – Wiktor Stribiżew