Regex - Escape with Negative Lookahead
-
30-10-2019 - |
Pergunta
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?
Nenhuma solução correta
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow