It seems I'm stuck again with a simple regex.
What I'd like:
- A number between 1 and 999
- Optional: a comma , sign
- If the comma sign is entered, minimum 1 decimal and maximum 3 decimals should be presebt.
Allowed:
100
999,0
999,999
999,99Disallowed:
-1
0
999,
999,9999
This is what I have so far:
^[0-9]{1,3}(?:\,[0-9]{1,3})?$
Any tips?
You can use this regex:
RegEx Demo
Main difference from OP's regex is use of
[1-9]
which matches digits 1 to 9 before rest of the regex.