Regex to Match Currency Amounts

Validate US dollar currency amounts with this regex pattern. Matches properly formatted values like $1,234.56 or $99.99 with commas. Free tool.

Regular Expression

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

Token Breakdown

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
\$Matches a literal dollar sign
\dMatches any digit (0-9)
{1,3}Matches between 1 and 3 times
(?:Start of non-capturing group
,Matches the literal character ','
\dMatches any digit (0-9)
{3}Matches exactly 3 times
)End of group
*Matches the preceding element zero or more times (greedy)
(?:Start of non-capturing group
\.Matches a literal dot
\dMatches any digit (0-9)
{2}Matches exactly 2 times
)End of group
?Makes the preceding element optional (zero or one times)
$Anchors at the end of the string (or line in multiline mode)

Detailed Explanation

This regex validates US dollar currency amounts in standard formatted notation. Here is the token-by-token breakdown:

^ — Anchors the match at the start of the string.

$ — Matches a literal dollar sign. The backslash escapes the $ to prevent it from being interpreted as the end-of-string anchor.

\d{1,3} — Matches the first group of one to three digits. Currency amounts start with one to three digits before the first comma (e.g., $1, $12, $123).

(?:,\d{3})* — A non-capturing group matching comma-separated thousands groups. Each group is a comma followed by exactly three digits. The * quantifier allows zero or more groups, supporting amounts from single digits to billions and beyond.

(?:.\d{2})? — An optional non-capturing group for cents. It matches a literal dot followed by exactly two digits. The entire group is optional, so both $100 and $100.00 are valid.

$ — Anchors the match at the end of the string.

This pattern matches currency amounts like $1.00, $99.99, $1,234.56, $1,000,000, and $0.99. It enforces proper comma placement (every three digits) and optional two-decimal-place cents.

The pattern is specific to US dollar formatting with commas as thousands separators and a period as the decimal separator. Other currencies and locales use different formatting conventions (e.g., European format uses periods for thousands and commas for decimals). For those formats, modify the separator characters accordingly.

Example Test Strings

InputExpected
$1,234.56Match
$99.99Match
$1,000,000Match
1234.56No Match
$12,34.56No Match

Try It — Interactive Tester

//
gimsuy
No matches found.
Pattern: 34 charsFlags: noneMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →