php.net |  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: 2020-03-10 09:11 UTC
From: michael dot nique at gmx dot de Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michael dot nique at gmx dot de
New email:
PHP Version: OS:

 

 [2019-06-14 20:44 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-15 02:17 UTC] requinix@php.net
-Status: Open +Status: Verified -Package: Regexps related +Package: PCRE related
 [2019-06-15 02:17 UTC] requinix@php.net
\\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.
 [2020-03-10 09:11 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349366
Log: Fix #78168: Reference Format is \n instead of \\n
 [2020-03-10 09:11 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-03-10 09:11 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-03-10 09:12 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=09483f34bc8bbece8699318d38b824a286505d16
Log: Fix #78168: Reference Format is \n instead of \\n
 [2020-03-10 14:27 UTC] mumumu@php.net
Automatic comment from SVN on behalf of mumumu
Revision: http://svn.php.net/viewvc/?view=revision&revision=349372
Log: Fix #78168: Reference Format is \n instead of \\n
 [2020-03-10 14:30 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=f2d6ebe224821dedaa3e8fc794aa7af4e110da4e
Log: Fix #78168: Reference Format is \n instead of \\n
 [2020-12-30 11:59 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=049c7cba057fbe405ccc69ab2d67e63a156d1480
Log: Fix #78168: Reference Format is \n instead of \\n
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC