I checked the following regexp for US prices (separating comma, separating dot), which works fine:
^[1-9][0-9]{0,2}(?:,?[0-9]{3}){0,3}(\.[0-9]{2})?$
It works, prices such as 30,000,000 are rejected. Only 2 decimal places are accepted.
I tried to exchange them to handle European prices:
^[1-9][0-9]{0,2}(?:.?[0-9]{3}){0,3}(\,[0-9]{2})?$
but this does not work, prices such as 30,000,000 are accepted, which is not true. Only 2 decimal places should be accepted.
What is wrong with these two regular expressions?
erwin source share