For a project, i need to separate string values into an list of strings. The strings are build as following:
string unprocessed = "\"foo,bar\",\"foobar\",\"shizzle ma nizzle\"";
i want to get int into an array like the following:
string[] processed = [] { "\"foo,bar\"", "\"foobar\"", "\"shizzle ma nizzle\""};
For this, im using a regex match system, that separates the code on the "," character combination. The code i have so far is as following:
Regex reg = new Regex(@"((?!(,""|"",)).)+");
string regmatch = "\"\"wubba,lubba\",\"dup dub\"\"";
var matches = reg.Matches(regmatch);
Assert.AreEqual(2, matches.Count);
Assert.AreEqual("\"dup dub\"\"", matches[1].Value); // passes
Assert.AreEqual("\"\"wubba,lubba\"", matches[0].Value); // fails because value = \"\"wubba,lubba
So far im getting one slight error, as seen in the example code. Right now i'm thinging I'm almost there. Can someone help me solve this regex issue? or is there a better way to do this?