Regular Expressions 101

Community Patterns

Community Library Entry

5

Regular Expression
Created·2015-03-09 19:02
Flavor·PCRE (Legacy)

/
(?:(?<=^)|(?<=,)) # start of line or comma (?:(?!$)\s)* # skip whitespace "? # skip opening quote mark ( (?<=").*?(?=") # capture value in quotes | # or ((?!,)\S)* # capture just value ) "? # skip closing quote mark (?:(?!$)\s)* # skip whitespace (?=$|,) # command or the end of the line
/
gmx
Open regex in editor

Description

It correctly handles simple values, empty values, and quoted values with commas inside.

Submitted by Viktor Lova aka nsinreal