0

I need to match a comma separated list of integers, where the max number/amount of elements in the list should be 5.

F.e. 1,1,5,6,253 and 12 and 234,6,43 etc. are allowed but 21,512,65,123,65,12 (here the elements are already 6) is not allowed.

I've got ^[0-9]+(,[0-9]+)*$ as to match the list of integers, but I am not sure how to restrict the max number of elements in the list.

I tried placing {5} before and after the * but both are wrong regex patterns.

Milkncookiez
  • 6,817
  • 10
  • 57
  • 96

0 Answers0