|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78168 Reference Format is \n instead of \\n
Submitted: 2019-06-14 20:44 UTC Modified: 2019-06-15 02:17 UTC
From: michael dot nique at gmx dot de Assigned:
Status: Verified Package: PCRE related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-06-14 20:44 UTC] michael dot nique at gmx dot de
From manual page:

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:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-15 02:17 UTC]
-Status: Open +Status: Verified -Package: Regexps related +Package: PCRE related
 [2019-06-15 02:17 UTC]
\\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.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Jan 23 04:01:24 2020 UTC