php.net |  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 - 31 = ?
Subscribe to this entry?

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

Under PHP4.0.3pl1 (tested) and lower the following Code worked as expected:
<?php
$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,
Christoph

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-28 12:17 UTC] andrei@php.net
This is fixed in 4.0.5.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC