$re = '/((([a-zA-Z]+)(\s)*(:))){1}(\s)*(((?:[\[])?(?:["])?((.)*)(?:["])?(?:[\]]?))?)?([,]?)/';
$str = '{
id: "00000000-0000-0000-0000-000000000000",
numericId: 0,
accountId: "00000000-0000-0000-0000-000000000000",
accountCode: "",
groups: ["group1"],
isTest: true,
ftpInfo: {
host: "127.0.0.1",
port: 21,
homeDirectory: "/",
fileMask: "*.txt",
username: "",
password: "",
isPassive: true,
isBinary: true
},
contactName: "",
contactEmailAddress: "",
createdOn: "1900-01-01T00:00:00",
modifiedOn: "1900-01-01T00:00:00"
}';
$subst = "\"$3\": $7$11";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php