正则表达式去除 HTML 中的所有注释和属性

// 去除所有html注释
$html = preg_replace('/<!--[\w\W\r\n]*?-->/mi', '', $html);
// 去除所有属性 如 style=xxx
$html = preg_replace('/(<[^\s\/>]+)\b[^>]*>/i', "$1>", $html);

附 正则表达式中模式修正符作用详解