Regular Expressions 101

Community Patterns

1...456

.NET CSV parser

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 - a month ago