Pattern library / Validation
Regex to Match Currency Amounts (Prices & Money)
Prices land in the text as $1,234.56, €1.234,56 and -$40.50, and all of them are one shape: an optional sign, a currency symbol, grouped digits, an optional cents part. The pattern below full-matches that shape and is RE2-compatible, so the same line works in JavaScript, Python, GA4 and BigQuery. It refuses bare numbers on purpose — if you only need the digits, use the number extraction pattern instead.
^[+-]?[$€£¥][0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?$
Load this pattern into the tester →
How the pattern works
[$€£¥]is a character class, so the symbols are literal and$needs no escaping inside it. Add your own currency by dropping it in:[$€£¥₹₩].[0-9]+takes the whole integer part,(?:[,.][0-9]{3})*accepts repeated thousands groups —1,234,567— and(?:[,.][0-9]{1,2})?an optional cents part. Grouping is optional, so$1234matches too.- The sign sits before the symbol (
-$40.50), which is how refunds and adjustments are written; move it after the symbol only if your data really does that. ^and$make it a full match — the same verdict GA4 filters give. Drop them to find amounts inside a sentence, and see GA4 match types for the per-surface rule.
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 | grouped dollars with two decimals | Try → |
€1.234,56 | Match | European separators, same shape | Try → |
$0.99 | Match | cents only, whole part is a single digit | Try → |
-$40.50 | Match | negative sign before the symbol (refund) | Try → |
1234.56 | No match | no currency symbol — bare numbers are a different job | Try → |
Total: $5.00 | No match | anchors require the whole input to be the amount | Try → |
Where to use it
JavaScript
const re = /^[+-]?[$€£¥][0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?$/;
re.test('$1,234.56'); // true
re.test('1234.56'); // false — no symbol
Python
import re
re.match(r'^[+-]?[$€£¥][0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?$', '€1.234,56')
BigQuery / GA4 (RE2)
SELECT REGEXP_CONTAINS('$1,234.56', r'^[+-]?[$€£¥][0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?$')
Common mistakes
- An unescaped decimal point matches any character:
[$€£¥][0-9]+.[0-9]{2}happily accepts$5x99. Keep the point inside the class ([,.]) or escape it as\.. - Shape is not legal money:
$1,23passes, and RE2 has no backreferences, so you cannot require the same separator in both slots. Strip the symbol and parse with your locale's number parser before doing arithmetic. - Full-match anchors are the GA4 behaviour:
Total: $5.00fails on purpose. On a "partially matches" surface, or to scan a log line for every price, delete^and$.
FAQ
How do I match a price with no currency symbol?
Drop the symbol class: [0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})? matches 1,249.50. When the amount sits inside a sentence, the number extraction pattern is the better tool.
Why does €1.234,56 match when the separators are swapped?
The group slot and the cents slot both accept , or ., because prices arrive in US (1,234.56) and European (1.234,56) form. The regex checks the shape only — which separator your locale means is decided when you parse the number.
How do I match USD, EUR or GBP codes instead of symbols?
Add the code as an alternative: ^[+-]?(?:[$€£¥]|[A-Z]{3})[0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?(?:[A-Z]{3})?$ — but any three uppercase letters then match, so prefer an explicit list such as (?:USD|EUR|GBP|JPY|IDR) over [A-Z]{3}.
Related patterns
Extract Numbers from String — Regex + Examples · Credit Card Regex — Visa, Mastercard & Amex Shapes · IBAN Regex — Validate International Bank Account Numbers
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.