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
  • 10,418
  • 17
  • 72
  • 122

1 Answers1

2

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

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

Live Demo

hwnd
  • 69,796
  • 4
  • 95
  • 132