I have the following JSON-encoded string:
$json = '"|\t|\n|\\\u0027|\\\u0022|"';
What is the most efficient way to escape all the (already) escaped chars / codepoints except \\\u0022 or \\\u0027? I though about using preg_replace() with a negative lookahead regular expression but it’s not working as I expected, the output should be:
$json = '"|\\\t|\\\n|\\\u0027|\\\u0022|"';
I’m feeling lost in this ocean of JSON-PHP-PCRE escaping, can someone help me out?
Something like this may work with the help of negative lookahead:
OUTPUT