|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37550 preg_match has string size limit
Submitted: 2006-05-22 15:12 UTC Modified: 2006-05-22 15:45 UTC
From: Arne dot Heizmann at csr dot com Assigned:
Status: Not a bug Package: Regexps related
PHP Version: 5.1.4 OS: Windows 2000
Private report: No CVE-ID: None
 [2006-05-22 15:12 UTC] Arne dot Heizmann at csr dot com
preg_match() stops working properly at some minimum string length.

Reproduce code:
    $str1 = 'a@b%c@d' . str_repeat ('=', 3333326);
    $str2 = 'a@b%c@d' . str_repeat ('=', 3333327);
    $regexp = '/^(.*)@(.*)%(.*)$/si';

    echo preg_match ($regexp, $str1) ? "Correct " : "Wrong ";  // works correctly
    echo preg_match ($regexp, $str2) ? "Correct " : "Wrong ";  // exhibits the bug

Expected result:
"Correct Correct "

Actual result:
"Correct Wrong "


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-22 15:45 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You reached the backtrace limit (BACKTRACE_LIMIT_ERROR).

With php 5.2 and up (cvs only yet), you can check the last preg error with preg_last_error.
 [2011-03-17 22:54 UTC] dicr at net dot dn dot ua
preg_match documentation does not include any comments about string. Also, the 
BUG appear for not so large strings. So, this is either undocumented feature or 
the BUG. Please, don't refer to help forum, because this is really happens !!!!
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 03:01:28 2024 UTC