Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

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

Description

Decimal numbers matcher with optional matching for exponent (12.4e7) and optional thousand comma separator matches both 1,234.05 and 1234.05. Also matches negative numbers (-1234.05)

Submitted by Mirco Sanguineti - 9 years ago