Answer the question
In order to leave comments, you need to log in
How to write an expression where (the last comma is optional)?
I want to check input tags. Tags consist of letters and numbers, separated by commas, there can be any number of spaces between tags.
The following expression almost copes: [ ]*([a-zA-Z0-9]+,[ ]*)*
the only annoying thing is that you need to put a comma after the last tag. How can I make the last comma optional?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question