这是我的代码:
$long = str_repeat('a very long string text', 100); // try changing 100 to 5000
$str = <<<STR
<abc>a short string text</abc>
<abc>$long</abc>
STR;
preg_match_all('@<abc>([^<>]+)</abc>@sU', $str, $matched);
print_r($matched);
它完全按预期工作。但是,当你将100次重复改为5000次后,跑
print_r($matched);
您将只得到短字符串出现的结果。
我的问题是如何使preg_match或preg_match_all与大字符串文本(大到1MB或更大)一起工作?