Regex for Integer (signed)

Matches an optionally signed whole number.

^[+-]?\d+$

Proof it works

6/6 sample tests passed · compiles: true

SampleShould matchResult
42 yes pass
-7 yes pass
+1000 yes pass
3.14 no pass
1e5 no pass
abc no pass

Try your own input

Related patterns