I want to validate that the user has entered a comma separated list of words only using regex, will this work/is there a better way:
$match = "#^([^0-9 A-z])(,\s|$))+$#";
This is not for parsing, as I will use explode for that, it is merely to validate that the user has correctly understood that values should be separated with commas.
I don’t know what the separate values should look like, but perhaps this is something that can help you:
When you know what your values should look like you can change
$value.Update
Taken this comment from the question
Just change
$valueNote, that I use the
i-modifier in$match, that will include all lowercase letters too.However, "real" csv allows a little bit more than this, for example you can put quotes around every value. I would recommend that you parse the line and then test every single value
str_getcsv()