I want to validate some fraction of cryptocurrencies, for example, I have the following VALID values
0,000001
0,000000001
1,00
1.000,00
Right now I have this regex for validating currency (yes, with comma instead of dot)
/^[1-9]\d{0,2}(\.\d{3})*,\d{2}$/
How can I do the same for the values above?
You might either match the more exact pattern starting with a digit 1-9, or match a pattern starting with a zero and have 1 or more digits after the comma:
^(?:[1-9]\d{0,2}(?:\.\d{3})*,\d{2}|0\d*,\d+)$