Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(([+-]?(?:\d*(?:\.(?=\d))?\d+))(?:(?:(?:(?<=\d)[Ee])?((?2)))(?<=\d))?)(?:(?<=\d)[, ](?=\d|[+-]|\.)((?1))[iIjJ])?$
/
g

Description

The regex verifies complex numbers in quite a few mixtures of different floating point representations, with extensive error checking - however, there may be edge cases which i haven't addressed, so feel free to put in more unit tests!

Submitted by anonymous - 8 years ago