Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^ (?: [+-]? # optional sign (?: # start a conditional group \d+ # either a nonzero number of digits | # or a decimal phrase \d* # optional digits preceding the decimal \.(?=\d) # a literal decimal followed by at least one digit \d* # optionally some more digits ) # note this group is mandatory! (?: # start an optional scientific notation group [eE] # the scientific notation character [+-]? # optional sign \d+ # after sci notation, you cannot go directly to a decimal )? ) $
/
gmx

Description

Matches real/FP numbers which may optionally also include a scientific notation/exponent part.

Submitted by Kevin Winner - 2 years ago