【发布时间】:2015-10-21 18:14:50
【问题描述】:
我在 PHP 中使用正则表达式剥离我的 HTML cmets。
$html = preg_replace('/<!--(.*)-->/Uis', '', $html);
但是,我不希望正则表达式删除我拥有的条件 IE TAGS
<!--[if lte IE 6]><html class="ie6 no-js">
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
有什么简单的方法吗?
编辑: 为方便起见,我在这里添加了相关的 HTML 代码: http://pastebin.com/dPGHHXjU (要么) 这里:https://regex101.com/r/yS8zM6/1
提前致谢
【问题讨论】:
-
preg_replace('/<!--([^<>]*)-->/Uis', '', $html); -
@AvinashRaj:您的解决方案不会删除任何评论,兄弟