PatternRegex
Match a currency amount
Extract a priced amount, symbol and digits together, from receipts, invoices, or pasted text in dollars, euros, pounds, or rupees.
Last updated
Matches
- Total: $1,250.00 due
- Price is €99.99
Doesn’t match
- Total is 1250.00 dollars
- Symbol alone: $ and nothing else
Why it’s written this way
The leading character class [₹$€£] anchors the match to one of four common currency symbols sitting directly against the number, then \d{1,3}(?:,\d{3})* allows an optional run of comma-grouped thousands before an optional (?:\.\d+)? decimal tail.
Every quantifier after the symbol is optional or repeatable rather than fixed, so the same pattern matches a bare $5, a grouped $1,250, and a precise €99.99 without needing three separate rules.
Edge cases to know
- →The symbol must sit directly against the digits — '$ 5' with a space in between, or the bare number followed by the word 'dollars', won't match.
- →It doesn't validate that comma groups are exactly three digits apart the way a stricter thousands pattern would, so a malformed grouping like $1,2,345 still passes.
- →Negative amounts and parenthesized accounting notation like ($50) aren't recognized — the pattern assumes a plain positive amount.