Doc #78168 [Opn->Ver]: Reference Format is \n instead of \\n

From: Date: Sat, 15 Jun 2019 02:17:45 +0000
Subject: Doc #78168 [Opn->Ver]: Reference Format is \n instead of \\n
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16756@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78168&edit=1 ID: 78168 Updated by: requinix@php.net Reported by: michael dot nique at gmx dot de Summary: Reference Format is \n instead of \\n -Status: Open +Status: Verified Type: Documentation Problem -Package: Regexps related +Package: PCRE related Operating System: Linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: \\n is because people are liable to use double-quoted strings so the backslash would have to be escaped. Doubled backslashes will work for both types of strings without needing a second thought. But IMO the section there is a bit overzealous on the "you need doubled backslashes" when the truth is that PCRE only wants one, so maybe it could be adjusted a bit. Previous Comments: ------------------------------------------------------------------------ [2019-06-14 20:44:36] michael dot nique at gmx dot de Description: ------------ --- From manual page: https://php.net/function.preg-replace --- The documentation states: "replacement may contain references of the form \\n or $n" I think it should be "\n" instead of "\\n", see test-script Test script: --------------- echo(preg_replace('/#.*#/', 'A\0B', '#test#')); Expected result: ---------------- A\0B Actual result: -------------- A#test#B ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78168&edit=1

« previous php.doc.bugs (#16756) next »