This is possible duplicate of many questions. But I have a slightly different scenario here off the many questions and answers I read.
I want to split a string by = but skip the = that may appear in double-quotes. Also, this double-quoted string in itself contains double quotes as well.
Example
string example1 = "propery=value";
string example2 = "property=\"value1=value2\"";
string example3 = "property= \" \"value1\" = value2 \" ";
string regex = "[=](?=(?:[^\"]* \"[^\"]*\")*[^\"]*$)"
string[] ex1 = Regex.Split(example1, regex) // result: [property], [value]
//Does not work for these cases
string[] ex2 = Regex.Split(example2, regex) // result: [property="value1=value2"]
//Expected result: [property], ["value1=value2"]
string[] ex3 = Regex.Split(example1, regex) // result: [property= \" \"value1\" = value2 \"]
//Expected Result: [property],["\"value1\"=value2"]
I checked on regexr.com and it seems to identify the correct =.