Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE2 (PHP >=7.3)

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

Description

This is the best regex I found that was able to correctly parse cells containing multiple lines (hard line breaks). Low number of steps with sufficient speed, and it doesn't require /x option either.

Source: https://gist.github.com/awwsmm/886ac0ce0cef517ad7092915f708175f

Submitted by thdoan - 5 months ago (Last modified 5 months ago)