Sounds like you need an expression like this:
[0-9a-zA-Z]+(,[0-9a-zA-Z]+)*
Posix allows for the more self-descriptive version:
[[:alnum:]]+(,[[:alnum:]]+)*
[[:alnum:]]+([[:space:]]*,[[:space:]]*[[:alnum:]]+)* // allow whitespace
If you're willing to admit underscores, too, search for entire words (w+
):
w+(,w+)*
w+(s*,s*w+)* // allow whitespaces around the comma
(Thanks to Alan for pointing out several of my failings!)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…