Numbersflags: g
USD Currency (Inline)
Match US dollar amounts inline in text: `$1,234.56`, `$99`, `$1,000,000.00`.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
jsJavaScript
const re = new RegExp("\\$\\d{1,3}(?:,\\d{3})*(?:\\.\\d{2})?", "g");
const input = "Total $1,234.56 plus tax of $99";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
pyPython
import re
pattern = re.compile(r"\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?")
input_text = "Total $1,234.56 plus tax of $99"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
goGo
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?`)
input := `Total $1,234.56 plus tax of $99`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
regexengine-agnostic
\$\d{1,3}(?:,\d{3})*(?:\.\d{2})? (flags: g)Raw source: \$\d{1,3}(?:,\d{3})*(?:\.\d{2})?
How it works
\$ matches the literal dollar sign. \d{1,3} matches the first 1–3 digits. (?:,\d{3})* matches additional thousands groups (comma + 3 digits). (?:\.\d{2})? optionally matches a decimal portion with exactly two digits (cents).
Examples
Input
Total $1,234.56 plus tax of $99Matches
$1,234.56$99
Input
Bonus $1,000,000.00 awardedMatches
$1,000,000.00
Input
no money mentionedNo match
—Common use cases
- •PII / financial data redaction
- •Receipt OCR post-processing
- •Sentiment / earnings call analysis
- •Marketing copy auditing for promised price ranges
Related patterns
US Currency (USD)
NumbersMatches USD currency amounts with optional $ sign, thousands separators, and cents.
Binary Number Literal
NumbersMatch binary number literals like `0b1010` or `0B11110000`.
Decimal Number
NumbersMatches decimal numbers, including integers and negatives.
Float / Scientific Number
NumbersMatch floating-point and scientific-notation numbers including `1.5`, `.25`, `1e10`, `-3.14E-2`.