Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Regular
Expressions
101
Regular
Expressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
(?<!\d,)(?<!\d)\d{1,3}(?:,\d{3})*(?!,?\d)
"
gm
Input 1
1
New
I need help finding a regex rule that should search in a large string/text and match numbers that have the format: 12,345,678 or 1,234,567 or 12,345 or 1,234. for example: for 12,345,678 it should match 12,345,678 and not 345,678 or 45,678 or anything similar I looked in: Regex help needed to match numbers but the answers either match 1 in 1,23,456 (should not at all because 1,23,456 is not a number) or match 23,456 in 12,23,456 (should not match at all) In creating a regex rule to match the correct format number, I tried first creating the rule of what it should not match(i.e., not 1,23,456), then I tried creating the rule of what it should match. The last rule I created matches in most cases, but not in all. MATCH: 1 12 123 1,234 12,345 123,456 1,234,567 12, NO MATCH: 1,24,567 1,234,5 1,2 1,2,567 12567
Substitution