簡體   English   中英

PHP preg匹配所有限制3725個字符

[英]PHP preg match all limit 3725 characters

如何增加搜索字符數限制? 現在示例中是3276個字符,但在3275中可以正常工作

ini_set("pcre.backtrack_limit", "23001337");
ini_set("pcre.recursion_limit", "23001337");

$str = "<div>";
for ($x=1;$x<=327;$x++){
    $str .= "1234567890";
}
$str .="123456";
$str .= "</div>";

$w1 = "/<div>((.*?|\n)*)<\/div>/";
preg_match_all($w1, $str, $matches);
print_r($matches);

嘗試禁用pcre.jit(不要使用PCRE的即時編譯):

<?php
ini_set("pcre.jit", "0");

$str = "<div>";
for ($x=1;$x<=327;$x++){
    $str .= "1234567890";
}
$str .="123456";
$str .= "</div>";

$w1 = "/<div>((.*?|\n)*)<\/div>/";
preg_match_all($w1, $str, $matches);
print_r($matches);
?>

您應該執行preg_last_error()才能知道失敗的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM