\d{1,3}(?:,\d{3})*
to match correctly placed commas (4,43,424
won't match)
https://regex101.com/r/kQ6fC9/3
There can be 1-3 digits before the first comma, and then (,xyz)
can repeat however times it wants, -,123,456
, ,123,456,789
and also no times - just a number 13.
This works perfectly for whole (integer) numbers that may be divided by commas for readability. If you need to add also decimals to it, it means that the number after the last comma has no limitations. (?<=^|\s)\d{1,3}(?:,\d{3})*(?:,\d+)?(?=\s|$)
should work for any number, including decimals, while avoiding faulty ones, https://regex101.com/r/kQ6fC9/4