Numbers

Integer

Matches whole integers, including negative numbers.

Try it in RegexPro

Pattern

regexJavaScript
/^-?\d+$/

Raw source: ^-?\d+$

How it works

`^-?` optionally allows a leading minus sign. `\d+` requires one or more digits. `$` anchors to end.

Examples

Input

42

Matches

  • 42

Input

-17

Matches

  • -17

Input

3.14

No match

Common use cases

  • Form validation
  • ID parsing
  • Configuration values

Related concepts