A general regex pattern which might fit your need is:

[A-Za-z0-9]+(?:\s*,\s*[A-Za-z0-9]+)*

Explanation:

[A-Za-z0-9]+      an initial alphanumeric term
(?:               (open non capturing group)
    \s*           optional whitespace
    ,             comma separator
    \s*           more optional whitespace
    [A-Za-z0-9]+  another alphanumeric term
)*                zero or more times (close non capturing group)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top