Regular Expressions 101

Community Patterns

Numbers or Fractions

0

Regular Expression
ECMAScript (JavaScript)

/
[-]?[0-9]+[,.]?[0-9]*([\/][0-9]+[,.]?[0-9]*)*
/
gm

Description

Matches integer numbers, floats and fractions of floats. I.e. "2", "-3.456", "3/4", "2.1/8".

Submitted by anonymous - 4 years ago