2016-05-24 99 views
0

我想使用preg_replace替换大型HTML文档中的某些noscript标签,我使用的正则表达式如下。PHP preg_replace函数导致net :: ERROR_CONNECTION_RESET

$regex = '/<noscript><iframe(.?)+width="'.$width.'"(.?)+height="'.$height.'"(.?)+<\/iframe><\/noscript>/m'; 
$html = preg_replace($regex, $customTag, $html); 

它不断地重置到我的服务器的连接。我究竟做错了什么?

+0

检查你的PHP日志,我不明白为什么'preg_replace()'会重置你的连接。如果你的文件很大,请检查php_ini值'max_execution_time'和'memory_limit'。 – Charleshaa

+0

已经做了,最大执行时间是120秒,内存限制是520M,它没有工作。 – Anfal

+0

尝试使用'(。+?)'而不是'(。?)+' –

回答

0

你应该改变(.?)+(.+?)

  • (.+?)将匹配的ungreedy方式的任何字符(除换行符)。