Regular Expressions 101

Community Patterns

Comma separated list of alphanumeric, underscore and minus - with spaces around commas

0

Regular Expression
PCRE (PHP <7.3)

/
^(?:[a-zA-Z0-9\-\_]++\ *+(?(?=\,)\,+\ *+|$))*+$
/
gm

Description

Check if a string matches the conditions of being a list of alphanumeric, underscore and minus only strings, separated by commas (which can have spaces on either side).

Submitted by anonymous - 5 years ago