Need a regular expression to validate number with comma separator. 1,5,10,55 is valid but 1,,,,10 is not valid.
This should do it:
^d+(,d+)*$
The regex is rather simple: d+ is the first number, followed by optional commas and more numbers.
d+
You may want to throw in s* where you see fit, or remove all spaces before validation.
s*
[+-]?d+
[+-]?d+(?:.d+)?
2.1m questions
2.1m answers
60 comments
57.0k users