I am creating a string array of comma separated values. I need to split the line on commas but not commas that are inside quotes as that could be part of the data.
For example:
\"421 15th Ave.\",\"Beaver Falls, PA\",\"S1\",
I wouldn't want it to split between the city and state for a new field.
Here is the code currently:
string[] fields = Regex.Split(lines[i], @",(?=(?:[^""]*""[^""]*"")*(?![^""]*""))");
It takes a long time to execute. Is there a better option I could be using?
Thanks for any help on this.
stringmethods.csvreader. Assuming you're using a decent one, this will already be handled and the code should be optimized.