DD
DevDash

Regex for Currency Amount (Generic)

Regex Pattern

^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$

Currency amount with ISO 4217 code (e.g. USD 1,234.56)

Quick Answer

The regex pattern for currency amount (generic) is `^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$`. Currency amount with ISO 4217 code (e.g. USD 1,234.56). This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
USD 1,234.56✓ Matches
EUR1000✓ Matches
GBP 99.99✓ Matches
$100✗ No match
1234.56✗ No match
US 100✗ No match

Code Examples

javascript

const regex = /^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$/;
const isValid = regex.test(value);

python

import re
pattern = r'^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^[A-Z]{3}\s?\d{1,3}(?:[,.]\d{3})*(?:[,.]\d{1,2})?$/', $value)) {
    echo "valid";
}

java

String pattern = "^[A-Z]{3}\\s?\\d{1,3}(?:[,.]\\d{3})*(?:[,.]\\d{1,2})?$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.