【问题标题】:preg_match has string size limitpreg_match 有字符串大小限制
【发布时间】:2011-05-30 07:02:14
【问题描述】:

preg_match 在 PHP 5.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";

【问题讨论】:

标签: php preg-match


【解决方案1】:

preg_last_error() 在第二次调用后返回 2 (=PREG_BACKTRACK_LIMIT_ERROR),因此您可能需要提高此值。

【讨论】:

  • 回溯限制已用完!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-12-24
  • 1970-01-01
  • 2012-10-25
  • 2018-11-19
  • 1970-01-01
  • 1970-01-01
  • 2022-07-08
相关资源
最近更新 更多