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
  • 9,728
  • 17
  • 68
  • 117

1 Answers1

2

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

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

Live Demo

hwnd
  • 67,942
  • 4
  • 86
  • 123