js代码正则
代码如下<script[^>]*?>.*?</script>"si", // 去掉 javascript
起初使用,m代表多行匹配,测试多次单行可以替换,多行没效果。
代码如下preg_replace("/<script.*?<\/script>/m", "", $html);
原来.不匹配换行,添加s修饰符正常:
代码如下preg_replace("/<script.*?<\/script>/ms", "", $html);
例子 利用tidy_parse_file工具
代码如下
$options = array("indent" => true,
"indent-spaces" => "4",
"wrap" => 4096);
$tidy = tidy_parse_file("/edit-table.html", $options);//此处改成你要处理的文档URL
tidy_clean_repair($tidy);
echo $tidy;
?>
[php删除html中js代码正则表达式]PHP删除HTML中JS代码正则表达式
http://m.bbyears.com/aspjiaocheng/53339.html
推荐访问: