Skip to main content
Regexflux

Integer Number

beginner

Matches positive and negative integers with optional thousands separators.

numberintegerparsingmath

Pattern

/-?\d{1,3}(?:,\d{3})*|\d+/g

Try It

0 of 7 strings matched

Explanation

Matches integers with optional negative sign and comma-separated thousands groups, or plain digit sequences.

Test Strings

Matching

  • 42
  • -100
  • 1,000,000
  • 999

Non-matching

  • abc
  • no-numbers-here
  • $$$

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support

Code Snippets

const regex = /-?\d{1,3}(?:,\d{3})*|\d+/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Related Patterns