|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51963 preg_replace returns NULL, if in line more than 991 blanks
Submitted: 2010-06-01 10:58 UTC Modified: 2010-06-02 23:48 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: lexx918 at mail dot ru Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.13 OS: Windows XP SP3
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:
Solve the problem:
27 + 11 = ?
Subscribe to this entry?

 [2010-06-01 10:58 UTC] lexx918 at mail dot ru
One of my regular expressions leads to return of emptiness to functions preg_replace if the initial line contains more than 991 blanks. Example more low. The first line works, the second dies also I lose all contents.

Test script:
$text = 'test'.str_repeat(' ', 991).'test'; // work
$text = 'test'.str_repeat(' ', 992).'test'; // empty :(

if ($text = preg_replace('/(.*?\s+)"([^\s]+.*?)/', '$1<quot1>$2', $text)) {
    echo "GOOD\n";
} else {
    echo "BAD\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-02 23:48 UTC]
-Status: Open +Status: Bogus
 [2010-06-02 23:48 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Checking the value of preg_last_error() after the fail will revelate you that there was a backtrack limit error. Which can be fixed by setting a new value for pcre.backtrack_limit directive. (the default is 100000)
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Jul 01 05:05:44 2022 UTC