Ashlin Ashlin - 1 year ago 63
Javascript Question

Regex: Comma separated values

I have been trying to make a regex that will: match only if all condition are met, will not match 1 to 10 or something like it and will ignore commas.

I have made

which almost works and will match to
as it is meant to but will also match to
. I can not work out how to stop this. So my question is how do I get the regex to know the difference between numerals and a single digit.

Answer Source

Make it match word boundaries around the number, using \b.