Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
"(?:[^"]|"")*"|[^,\n]+|(?=,)(?<=,)|^|(?<=,)$
/
gms

Description

matches the exact fields of CSV files supports: qouted fields quoted fields containing commas, doubble quoutes, and newlines empty fields empty records arbitrary white space in, and outside quoted fields

Submitted by Austin - 9 years ago