Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
preg_split("/({{\s*(?:(?!}}).)+\s*}})/s", file_get_contents('data.txt'));
该行使 Apache 重置连接。data.txt大约为 12 kB。
data.txt
我做错了什么,我可以以某种方式优化正则表达式吗?
试试这个正则表达式:
/({{(?>(?:[^}]|}[^}])+)}})/s
主要改进:
(?>…)
(?:[^}]|}[^}])+
尝试将文件读入变量而不是将其传递给 preg_split。我认为它是 file_get_contents problem rather thanpreg_split`。
problem rather than