Numbers

Decimal Number

Matches decimal numbers, including integers and negatives.

Try it in RegexPro

Pattern

regexJavaScript
/^-?\d+(\.\d+)?$/

Raw source: ^-?\d+(\.\d+)?$

How it works

`^-?\d+` matches optional sign and integer part. `(\.\d+)?` optionally matches a decimal point and fractional digits.

Examples

Input

3.14

Matches

  • 3.14

Input

-0.001

Matches

  • -0.001

Input

42

Matches

  • 42

Common use cases

  • Price input
  • Scientific data
  • Form validation

Related concepts