Regular expression to match numbers with semicolon with decimal places
Your regex expects either a decimal point or a decimal point followed by two decimal digits. It depends what you want, but you can make your regex match your suggestion by doing the following:
^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{1,2})?$
I changed {2}
near the end to {1,2}
to give one or two decimal digits after the decimal point. I also changed the value .
to \.
because simple .
in regex means "match any character".
source to share
This part: "(.\d{2})?"
says that your number can optionally end with a "dot followed by two digits", but not necessarily. Because you don't have a "dot followed by two digits" anywhere in your example, and nothing else that allows a dot matches.
Also, noticed duffymo's ass, you probably want to avoid the dot so that it matches full stop instead of any character.
source to share