php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43485 preg_replace not matching
Submitted: 2007-12-03 14:24 UTC Modified: 2007-12-03 15:50 UTC
From: cvlug at xs4all dot nl Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.5 OS: windows xp
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cvlug at xs4all dot nl
New email:
PHP Version: OS:

 

 [2007-12-03 14:24 UTC] cvlug at xs4all dot nl
Description:
------------
preg_replace not matching, where it should match n(same for preg_match)

Reproduce code:
---------------
$regex='/(.*)<[^>]*submenu[^>]*>/mis';
$str is on url: http://www.koopjespakker.nl/test/preg_match_data/str_for_php.txt

$modified_string = preg_replace( $regex, 'sss', $str);


Expected result:
----------------
a replaced string (other then the input string, $str)

Actual result:
--------------
"" (preg_replace return nothing)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-03 15:50 UTC] felipe@php.net
The backtrack limit was exhausted.
Using preg_last_error(), it'll show 2. (PREG_BACKTRACK_LIMIT_ERROR)

See http://br.php.net/manual/en/ref.pcre.php#ini.pcre.backtrack-limit
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 16:00:02 2025 UTC