php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46686 preg_replace returns NULL
Submitted: 2008-11-26 15:09 UTC Modified: 2008-11-26 22:32 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: adi_helfenstein at yahoo dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.6 OS: Linux (SUSE)
Private report: No CVE-ID: None
 [2008-11-26 15:09 UTC] adi_helfenstein at yahoo dot com
Description:
------------
The preg_replace function returns a NULL value on a not NULL input string. Even if there is no problem with backtrack_limit and recursion_limit.
The preg_last_error() returns 0.

Reproduce code:
---------------
$search = array("s1"=>"s1");   //In reality the arrays have 3000 entries
$repl = array("s1"=>"S1");
$str = "bla";
$str = preg_replace($search,$repl,$str);
echo $str;

Expected result:
----------------
bla

Actual result:
--------------
NULL

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-26 21:23 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You need to delimit your regular expression.
 [2008-11-26 22:32 UTC] adi_helfenstein at yahoo dot com
Ups, i've forgotten the delimiters in the short example above.
The same problem happens when i write:
$search = array("s1"=>"/s1/");
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 20:01:31 2024 UTC