|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10038 preg_replace("/([_%&])/","\\\\1",$text) does not work as expected
Submitted: 2001-03-28 12:14 UTC Modified: 2001-03-28 12:17 UTC
From: reeg-pb at junetz dot de Assigned:
Status: Closed Package: PCRE related
PHP Version: 4.0.4pl1 OS: Linux (Debian)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: reeg-pb at junetz dot de
New email:
PHP Version: OS:


 [2001-03-28 12:14 UTC] reeg-pb at junetz dot de
I want to replace _ with \_, % with \% and & with \&.

Under PHP4.0.3pl1 (tested) and lower the following Code worked as expected:
$text = "Test with_ and %";
$text = preg_replace("/([_%&])/","\\\\1",$text);
echo $text;

But under PHP4.0.4pl1 the output is:
Test with\\1 and \\1

PHP is compiled as Module with Apache.

Thank you,


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-28 12:17 UTC]
This is fixed in 4.0.5.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 20:03:33 2021 UTC