Im trying to split a string in C#. The string looks like this:
string line = "red,\"\",blue,\"green\",\"blue,orange\",,\"black\",yellow";
The result should be:
string[] result = { "red", "", "blue", "green", "blue,orange", "", "black", "yellow" };
Note that the delimiter is "," but inside double quotes it is ignored. Also note that not every substring between the delimiter is surrounded by quotes. I would like an answer where the delimiter is a string if possible. I don't mind if the double quotes are included inside the elements of the result array, like:
string[] result = { "red", "\"\"", "blue", "\"green\"", "\"blue,orange\"", "", "\"black\"", "yellow" };