Regular Expressions 101

Simple Number

Open Workspace
  • JavaScript
  • Match
6

Regular Expression

/
^[\-]{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