hoping someone can help me as i've realisticaly sunk 12+ hours into trying to solve this problem -
for some odd reason a comma separated string list value within a JSON string is being deserialised from
'High','Low','Medium'
to the value in the an object as being:
'''High'',''Low'',''Medium'''
All these extra single quotes seem to break things, so thought about somehow removing them via a regex pattern, possibly splitting into a list further and joining them with the correct amount of single quotes (one either side of a value, as it is on the incoming json string).
I thought I Would try my hand at simply extracting the values between a matching set of quotes and I had found a pattern that worked, but later found it did not (see the commented out part) and the second pattern I have there seemed to work on regex101 but I think that is just highlighting all the single quote pairs
//parameter.Value = Regex.Replace(parameter.Value, "/('+')/g", "'");
string[] values = Regex.Split(parameter.Value, @"/(?<![a-zA-Z])'|'(?![a-zA-Z])/g");
for (int j = 0; j < values.Length; j++)
values[j] = string.Format("'{0}'", values[j]);
parameter.Value = string.Join(",", values);
I was hoping someone would be able to help me out with pointing out where I may be going wrong in my pattern? I really have tried but that comma separated list could contain comma's and special characters in themselves (including apostrophe's) making it that bit harder.
Any help or guidance appreciated
Update
Thanks to @Wiktor Stribiżew for pointing out an obvious lapse in thought to me, problem is resolved. Appeared to be using wrong method along with string literal's in the pattern.
Other very reasonable options in the replies, so thanks to them too.