regexhelper
Test a pattern. Copy a ready-made one. No signup.

Regex to Match a Dollar Amount

Copy the pattern, paste text with prices, and watch each dollar amount light up. Below: how it handles thousands separators and cents.

Regex pattern

/\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?/g

This matches a US dollar amount like $1,234.56 with optional thousands separators and optional two-decimal cents. It checks formatting only, not that the number is a valid price.

/ /

What this pattern matches

It matches a dollar sign followed by a number that may use comma thousands separators and an optional two-digit cents part.

Part by part

\$ — a literal dollar sign (escaped because $ is special).

\d{1,3}(?:,\d{3})* — one to three leading digits, then any number of comma-grouped triples, so both 9 and 1,250 work.

(?:\.\d{2})? — optional cents.

Amounts without commas

If your data has no separators (e.g. $1250.00), use \$\d+(?:\.\d{2})? instead.

Use it in your code

Python
import re
text = "Total $1,250.00, tax $9.99, tip $15. Not a price: $ or 100 dollars."
pattern = r'''\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?'''
for m in re.finditer(pattern, text):
    print(m.group())
JavaScript
const text = "Total $1,250.00, tax $9.99, tip $15. Not a price: $ or 100 dollars.";
const re = new RegExp(String.raw`\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?`, "g");
console.log(text.match(re));

FAQ

Does it require cents?

No. The (?:\.\d{2})? group is optional, so $15 matches as well as $15.00.

Does it handle thousands separators?

Yes. It matches grouped triples like $1,250,000 via (?:,\d{3})*.

What about other currencies?

Swap the \$ for the symbol you need, e.g. £ or €, or use a character class [\$£€].