Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
.NET 7.0 (C#)

@"
^(?!$)(?:(?<=^|,)(?<start>)(?<quote>"")?(?(quote)(?>[^""]|"""")+\<quote>(?<-quote>)|[^,\n]*)(?<value-start>),?)+$
"
gm

Description

Parses CSV files using comma (,) as delimiter and double quote (") as quoted-field tag. Features:

  • Respects empty fields, including at the beginning and at the end of the line
  • Respects line breaks in quoted fields
Submitted by kevinhp - 3 months ago