Regular Expressions 101

Community Patterns

Decimal numbers (plus exponent)

1

Regular Expression
PCRE (PHP <7.3)

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

Description

Matches decimal numbers also with exponent (23.8e12) It does not match silly things like 00000000000.0000000000 as other "decimal number regex"

Submitted by Mirco Sanguineti - 8 years ago