Advertisement

Pattern library / Numbers & Codes

Regex to Match US Dollar Amounts

Accepts optional leading $, thousands separators, and exactly two decimals. Adjust the decimal count for cents-less currencies.

The pattern
^\$?[-+]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
$1,234.56Matchstandard amountTry →
1234.5No matchone decimal digitTry →
$1,23No matchbad thousands groupingTry →
-$50.00No matchsign after $Try →
0.99Matchless than a dollarTry →
1000No matchmissing thousands separatorTry →
1,000Matchthousands separator okTry →

Where to use it

JavaScript

const re = /^\$?[-+]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?$/;
re.test('$1,234.56');  // true

Python

import re
re.match(r'^\$?[-+]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?$', '$1,234.56')

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.