Regex for Currency Amount (USD)
Matches US dollar amounts with optional $ sign, thousand separators, and cents. Examples: $1,234.56, 99.99, $1000.
Pattern
/^\$?\d{1,3}(,\d{3})*(\.\d{2})?$/Pattern Breakdown
| Token | Explanation |
|---|---|
| ^ | Start of string |
| \$? | Optional dollar sign |
| \d{1,3} | 1-3 initial digits |
| (,\d{3})* | Optional comma-separated thousands |
| (\.\d{2})? | Optional cents (dot and 2 digits) |
| $ | End of string |
Test Examples
| Input | Match? |
|---|---|
| $1,234.56 | Match |
| 99.99 | Match |
| $1000 | Match |
| $1,23.45 | No match |
| 1.2 | No match |
Common Use Cases
- Price input validation
- Invoice parsing
- Financial data extraction
Variations
^\$?[\d,]+(\.\d{2})?$Simpler with less strict formatting
Other Regex Patterns
Want to test this pattern with your own data?
Open the Regex Tester