Regular Expressions 101

Community Patterns

Simple Number

6

Regular Expression
ECMAScript (JavaScript)

/
^[\-]{0,1}[0-9]+[\.][0-9]+|[\-]{0,1}[0-9]+$
/
g

Description

Verifies Number is a negative/positive number. Number may be a decimal, but if it is, it requires at least one number before and after the decimal place. Decimal numbers may also be negative or positive. Only 1 decimal place is allowed.

Submitted by David P Smith - 8 years ago