2017-12-28 2 views
0

검색 문자 제한을 늘리는 방법은 무엇입니까? 지금 예에 3276 자하지만, 3275에 확인의 작품PHP preg match all 3725 자

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); 
+0

나는 그것이 패치되지 않은 PHP 버그라고 생각합니다. https://bugs.php.net/bug.php?id=45735#1365812629 – MonkeyZeus

+1

^또는 - https://stackoverflow.com/questions/17926195/php-preg- match-length-3276-limit – splash58

+0

http://php.net/manual/en/pcre.configuration.php가 변경되지 않으면이 제한을 유발하지 않도록 정규 표현식을 수정해야 할 것입니다. – MonkeyZeus

답변

1

pcre.jit을 해제하십시오 (PCRE의 JIT 컴파일을 사용하지 않음) :

<?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()을 실행해야 무엇이 실패했는지 알아라.

+0

오류 6 : PREG_JIT_STACKLIMIT_ERROR –

+0

장소에 ini_set ("pcre.jit", "0"); 내가 작성한 코드 에서처럼 맨 위에. 그것은 내 컴퓨터에서 나를 위해 작동합니다. – jeprubio

+0

@ SławomirKudła'pcre.jit' 설정은 PHP 7에서 소개되었습니다. 어떤 PHP 버전을 사용하고 있습니까? – MonkeyZeus