I want to find and match currency in a given text. Formats that are accepted are:
- $10
- $10.25
- $999,000
- $2 billion
- $625 million
This is my regex so far:
var money_vals = $('body').text().match(/\$\d+\.?\d+(\,\d+)?(thousand|million|billion|trillion)?/g);
However, it doesn't match $2 billion or the $625 million or any value followed by million/billion/trillion. Also, after adding $5 to one of the paragraphs in my text, I realized it doesn't get matched.
Could anyone please help?