Q:

Split string at specific character but ignore some cases C# LINQ

I would need to split a string by comma but to ignore certain cases.
For example this string (after each comma is a space character):
my word 1, my word 2, my word 3, "my word x, my word y, my word z", my word 4, my word 5
should be split so that will display:
my word 1
my word 2
my word 3
"my word x, my word y, my word z"
my word 4
my word 5
Basically all words should be split after the comma, except the ones that are in double quotes should be shown as they are with the quotes.

A:

string text = @"my word 1, my word 2, ""my word x, my word y"", my word 3";
string pattern = @"[^,""]+|""([^""]*)""";
IEnumerable<string> result = Regex.Matches(text, pattern).Cast<Match>()
                                  .Select(m => m.Value.Trim())
                                  .Where(s => !String.IsNullOrWhiteSpace(s));

Result:
my word 1     
my word 2    
"my word x, my word y"    
my word 3

