php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39947 preg_replace failed to replace contiguous char
Submitted: 2006-12-25 18:11 UTC Modified: 2006-12-25 18:46 UTC
From: dlanoire at neuf dot fr Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.0 OS: Windows XP SP2
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: dlanoire at neuf dot fr
New email:
PHP Version: OS:

 

 [2006-12-25 18:11 UTC] dlanoire at neuf dot fr
Description:
------------
When I try replace the dot by "_d_", preg_replace fails to replace all dots separated by only 1 character. Only One substitution by 2 is working.

Reproduce code:
---------------
$texte = preg_replace("/(\w)\.(\w)/", "$1_d_$2", "a.b.c.d.e.f");


Expected result:
----------------
The result is a_d_b.c_d_d.e_d_f

Actual result:
--------------
The result should be a_d_b_d_c_d_d_d_e_d_f

On the other side, the replacement below works and gives the good result : aa_d_bb_d_cc_d_dd_d_ee_d_ff

$texte = preg_replace("/(\w)\.(\w)/", "$1_d_$2", "aa.bb.cc.dd.ee.ff");

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-25 18:46 UTC] tony2001@php.net
I get the very same result using Perl script, which means it's a PCRE library bug/feature and it should be reported to PCRE developers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 06:01:35 2024 UTC