Regular Expression To Match Comma Separated Numbers

Comma-separated numbers are a problem that many people face. Regular Expression allows you to match comma-separated-values, which gives you the flexibility to extract your data.

This is a regular expression to simply match and validate comma-separated numbers in your data. I hope this Regular Expression will help people who have been finding a solution for matching comma-separated values.

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

Matches:

  • 1
  • 12
  • 1,2,3

Non-matches:

  • 1.2.3
  • a,b,c
  • abc

See Also: