"key1"="value1 http://www.example.com?a=1";"key2"="value2 http://www.example.com?a=2";
I need to split the above line 2 times, the first time it is the comma character ; and the second time on the = sign.
It doesn’t work correctly because the value part has the = sign in it also.
My code doesn’t work as it was assuming the value part doesnt’ have an = sign in it, and it isn’t using regex simply String.Split(‘=’).
Can someone help with the regex required, I added double quotes around both the key/value to help keep things seperate.
Use the
String.Split(char[], int)overload (http://msdn.microsoft.com/en-us/library/c1bs0eda.aspx). The second parameter will limit the number of substrings to return. If you know your strings will always have at least 1 equal sign (key/value pairs), then set the second parameter to 2.–
Result: