Advertisement

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.

The pattern
^[+-]?[$€£¥][0-9]+(?:[,.][0-9]{3})*(?:[,.][0-9]{1,2})?$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
$1,234.56Matchgrouped dollars with two decimalsTry →
€1.234,56MatchEuropean separators, same shapeTry →
$0.99Matchcents only, whole part is a single digitTry →
-$40.50Matchnegative sign before the symbol (refund)Try →
1234.56No matchno currency symbol — bare numbers are a different jobTry →
Total: $5.00No matchanchors require the whole input to be the amountTry →

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

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

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}.

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.