1

I know the following regex will match a single integer, as well as a list of comma delimited integers:

/^\d+(?:,\d+)*$/

How can i turn this into only matching a list of integers? A single integer should not match. 123,456 and 634,34643,3424 should match.

David
  • 8,948
  • 16
  • 63
  • 116

1 Answers1

2

You would use the + operator meaning "one or more" times instead of * to repeat your group.

/^\d+(?:,\d+)+$/

Live Demo

hwnd
  • 65,661
  • 4
  • 77
  • 114