Regular Expressions 101

Community Patterns

Match US Currency Amount

1

Regular Expression
PCRE (PHP <7.3)

/
\$?\s*(\d{1,3}(,\d{3})+|\d+)(\.(\d\d))?
/

Description

Group 1 has dollar amount with or without commas, Group 4 has optional cents.

Submitted by anonymous - 10 years ago