When testing an answer for another user\'s question I found something I don\'t understand. The problem was to replace all literal \\t \\n \\r
\\t
\\n
\\r
Its works in perl because you pass that directly as regex pattern /(?:\\[trn])+/
/(?:\\[trn])+/
but in php, you need to pass as string, so need extra escaping for backslash itself.
"/(?:\\\\[trn])+/"
The regex \ to match a single backslash would become '/\\\\/' as a PHP preg string