You can use the following regular expression to match numbers starting at new line, having comma separator between groups of 3 digits.
^(?:\d{1,3}(?:(,?)\d{3})?(?:\1\d{3})*)$
Details:
^
asserts position at start of a line.
?:
Match expression but do not capture it.
\d
matches a digit (equal to [0-9]).
{1,3}
Quantifier — Matches between 1 and 3 times, as many times as possible, giving back as needed.
- Capturing Group
(,?)
matches the character ,
literally.
\1
matches the same text as most recently matched by the 1st capturing group.
{3}
Quantifier — Matches exactly 3 times.
$
asserts position at the end of a line.
? (the second
\d` is missing). – Alexander Mashin Oct 3 '20 at 8:00