Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^(?<real>(?<decimal>[+-]?(?:\d*(?:\.(?=\d))?\d+))(?:(?:(?:(?<=\d)[Ee])?((?&decimal)))(?<=\d))?)(?:(?<=\d)[, ](?=\d|[+-]|\.)((?&real))[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