Reputation: 187
Please, help me to compose a regular expression to match digits, chars (case doesn't matter) and commas, but with first, last or several in a row commas invalid. Valid string examples: "123,АВc,0aB12,3c", "ABc", "567". Invalid string examples: "123,,456789"; ","; ",,"; ",123,456"; "123,456,".
Upvotes: 0
Views: 134
Reputation: 700252
Match some alphanumerics, then optionally groups consisting of a comma followed by some alphanumerics:
^[\dA-Za-z]+(,[\dA-Za-z]+)*$
Upvotes: 1