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:
- Regular Expression To Match Pipe-Delimited String
- Regular Expression To Match CSV Data
- Regex To Match Comma Before & After A String
- Regex To Match Comma Delimited String
- Regex To Match Comma Separated Emails
- Regex To Match Numbers Containing Only Digits, Commas, and Dots