How can I separate the challenge string below into an array with a regex pattern?
For example:
$str = '{varA: "value, A", varB: "value:B", varC: "value C", varD: "value\"D\""}';
// remove both curved brackets
$trimStr = substr($str, 1, strlen($str)-1);
preg_match_all("/(.*?):\"(.*?)\",/sm", $trimStr, $m); // would like the regex to ignore the ',' and double quote in the value string too
Into an array where
arr[0] = 'varA: "value, A"';
arr[1] = 'varB: "value:B"';
arr[2] = 'varC: "value C"';
arr[3] = 'varC: "value \"D\""';