|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: lexx918 at mail dot ru
New email:
PHP Version: OS:


 [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: Mon Jun 27 00:05:44 2022 UTC