Php preg_匹配有字符串大小限制

Php preg_匹配有字符串大小限制,php,preg-match,Php,Preg Match,preg_match在PHP5.2.5上有str的限制 <?php $str1 = 'a@b%c@d' . str_repeat ('=', 33326); $str2 = 'a@b%c@d' . str_repeat ('=', 33327); $regexp = '/^(.*)@(.*)%(.*)$/si'; echo preg_match ($regexp, $str1) ? "Correct " : "Wrong "; // works corr

preg_match在PHP5.2.5上有str的限制

<?php
    $str1 = 'a@b%c@d' . str_repeat ('=', 33326);
    $str2 = 'a@b%c@d' . str_repeat ('=', 33327);
    $regexp = '/^(.*)@(.*)%(.*)$/si';

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

第二次调用后返回2(=PREG\u BACKTRACK\u LIMIT\u ERROR),因此您可能希望提高此值

这不是一个bug,这是一个特性:回溯限制已用尽!