regex for money values in JavaScript

Viewed 31451

Been out of the regex game for a while. Trying to come up with something that will allow the user to enter a money value either with/without dollar sign or with/without commas. For example, all the of the following values should be valid:

5
5.1
5.10
$5
500,000
500,000.1
500,000.10
$100,000,000.50
etc....

Could someone please help me out?

5 Answers
var currencyRegex = /^[$£€]\d+(?:\.\d\d)*$/g;

Example: $10 or £10 0r €10 but if you use simple 10 this will be wrong

Related