This is something of a follow up from a previous question. The requirements have changed, and I'm looking for some help with coming up with regex for either a comma separated number or a number with no commas. Sample input is below, along with some failed attempts.
Any help is appreciated.
Acceptable input:
1,234,567
1234567
Unacceptable input:
1234,567
1,234567
Some failed attempts:
^(\d{1,3}(?:[,]\d{3})*)|((\d)*)$
^\d{1,3}((?:[,]?\d{3})*|(?:[,]\d{3})*)$
Original success:
^\d{1,3}(?:[,]\d{3})*$