Regular Expression To Match CSV Data

Category: Strings

A regular expression that matches and validates comma-separated values (CSV data).

/^(?<field1>[^,]+),(?<field2>[^,]+),(?<field3>[^,]+)$/

Matches:

  • regex,pattern,com
  • 123,456,789
  • ABC,DEF,GHI

Non-matches:

  • regex.pattern.com
  • 123:456:798
  • ABC DEF GHI

See Also:

Rate This Regex
Sending
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.