Emae, here I reworked ...
A shielded zero in this case is a reference to a mask:
replacement
may contain links like \\ n, or (starting with PHP 4.0.4) $ n, with the latter option being preferred. Each such link will be replaced by a substring corresponding to the nth submask. n can take values from 0 to 99, and the link \\ 0 (or $ 0) corresponds to the occurrence of the entire template. Submasks are numbered from left to right, starting from one. To use the backslash, it must be duplicated (PHP string "\\\\").
http://php.net/manual/ru/function.preg-replace.php
UPDATE
When inserting a quotation with PHP.Net, it was published not quite accurately: backslashes were “eaten”. This was noticed in the comments to the answer. Now everything is corrected - the quotation is exact ... Nevertheless, as I noted, both options work (that is, \0
and \\0
):
$str = 'AaaBbbCcc'; echo preg_replace('/(?<![AZ])[AZ]/', ' ', $str); // aa bb cc echo "\n"; echo preg_replace('/(?<![AZ])[AZ]/', ' \0', $str); // Aaa Bbb Ccc echo "\n"; echo preg_replace('/(?<![AZ])[AZ]/', ' \\0', $str); // Aaa Bbb Ccc
https://repl.it/Cjmh
Why, I don’t know, I think this is a separate issue.