I'd like to know how to validate categories with regular expressions. So I have a list of categories separated by commas. Each word must have a maximum of 20 characters, I need to validate each comma if the word has alphanumeric characters.
I need to release the spaces as I did below, but the category must be at least 1 character, but it can not be made of space.
Nothing, look ---- That can not happen to be space between the commas.
I started doing this:
^[a-zA-Z0-9 ]{1,20}$
Car, motorcycle, knife, nothing
Someone has an idea how I can do this.