Skip to main content
Regexflux

CSV Field

intermediate

Matches individual fields in comma-separated value data.

csvparsingdatatabular

Pattern

/(?:"([^"]*(?:""[^"]*)*)"|([^,\r\n]*))/g

Try It

0 of 4 strings matched

Explanation

Matches CSV fields: either a double-quoted string (with escaped double quotes as "") or an unquoted value terminated by comma, CR, or LF.

Test Strings

Matching

  • "Hello, World"
  • simple_value
  • "She said ""hi"""
  • 123

Non-matching

    Language Compatibility

    LanguageSupport
    JSFull support
    PYTHONFull support
    JAVAFull support
    PHPFull support
    GOFull support

    Code Snippets

    const regex = /(?:"([^"]*(?:""[^"]*)*)"|([^,\r\n]*))/g;
    const text = "your text here";
    const matches = text.match(regex);
    console.log(matches);

    Related Patterns