Regex To Match Positive or Negative Number

A regular expression to match a positive or negative integer value.

/^-?\d*\.?\d+$/

Matches:

  • 100
  • -100
  • 0.15

Non-matches:

  • abcd
  • 1,000

See Also: