Regex To Match Comma Delimited String

A regular expression that parses and matches comma delimited strings.

/^([A-Za-z0-9]\s?)+([,]\s?([A-Za-z0-9]\s?)+)*$/

Matches:

  • 123,456
  • abc,def,ghi
  • abc123

Non-matches:

  • abc123,
  • ,abc123

See Also: