最近做一个问题,去除html中代码的JS脚本,代码如下
1 5 6 kkyz
m,dfd 7 10 11 ook12 EOF;13 14 echo "orginal text: \n\n" . $text . "\n\n";15 $pattern1 = "@ (.*?)@is"; #等效于"@ (.*)@isU"16 #末尾的i表示忽略大小写,s表示.可以匹配换行符,U与?等效,表示关闭无限匹配17 $pattern2 = "@ (.*)@is"; #这是无限匹配的pattern,php默认就是无限匹配18 $text1 = preg_replace($pattern1, "", $text);19 $text2 = preg_replace($pattern2, "", $text);20 echo "text1: \n\n" . $text1 . "\n\n";21 echo "text2: \n\n" . $text2 . "\n\n";22 ?>
结果如下: