Integer Number
beginnerMatches positive and negative integers with optional thousands separators.
numberintegerparsingmath
Pattern
/-?\d{1,3}(?:,\d{3})*|\d+/gTry 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
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full 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);