Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2017-05-10 17:00
Flavor·PCRE (Legacy)

/
^(([+-]?(?:\d*(?:\.(?=\d))?\d*))(?:(?:(?<=\d)[Ee])?((?2)))(?<=\d))?$
/
g
Open regex in editor

Description

The regex verifies floating point numbers in decimal or scientific notation 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 Tamoghna Chowdhury