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.
How the pattern works
\$?— optional dollar sign.[0-9]{1,3}(,[0-9]{3})*— thousands-grouped integer part.(\.[0-9]{2})?— optional two-decimal cents.- For European formats (1.234,56), swap
.and,.
Test it: match & no-match examples
Every row is loaded straight into the tester — click Try to see the match live:
| Input | Result | Why | |
|---|---|---|---|
$1,234.56 | Match | standard amount | Try → |
1234.5 | No match | one decimal digit | Try → |
$1,23 | No match | bad thousands grouping | Try → |
-$50.00 | No match | sign after $ | Try → |
0.99 | Match | less than a dollar | Try → |
1000 | No match | missing thousands separator | Try → |
1,000 | Match | thousands separator ok | Try → |
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.
FAQ
Related patterns
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.