Currency Regular Expression

Category: Numbers | Views Total: 5 views

A regular expression that matches all valid currency formats.

Currency amount with optional thousands separators, negative numbers, and two-digit fraction:

/^-?\d+(,\d{3})*(\.\d{1,2})?$/

Examples:

  • 100
  • -0.99
  • 12,345,678.90

Currency amount (no thousands separators, must be positive, two-digit fraction):

/(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/

Examples:

  • 100
  • 0.99
  • 1234567890

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Leave a Reply