I am trying to create a regex to have a number only stat from 1 and max length without decimal 10, decimal 2 I try this regex ^[1-9][0-9]{0,9}([,.][0-9]{0,2})?$
now facing the issue of comma separator not accepting amount validation.
Valid
1,000
1,500.99
150,000.09
invalid
0000
1000
CodePudding user response:
Assuming you want:
- To restrict the amount of digits before decimals to a max of ten;
- To optionally include decimals with a max of 2 digits (and at least one);
Then try:
^(?!\d \d(?:,\d ){3})[1-9]\d{0,2}(?:,\d{3}){0,3}(?:\.\d\d?)?$