Regular Expressions 101

Community Patterns

Float

1

Regular Expression
ECMAScript (JavaScript)

/
^\-?\d+(\.(?=\d))?\d*$
/
mg

Description

Tests if a string can be parsed as a number which may contain a fractional component. May be negative. Plus sign and scientific notation are not supported.

Valid: '1234', '-1234', '-1.234', '1234.1234' Not valid: '1.1.1', '+1', '.1', '-.1', '10.1234E10', '1.'

Submitted by Gary Ott - 8 years ago