I\'m currently using PHP and a regular expression to strip out all HTML comments from a page. The script works well... a little too well. It strips out all comments includin
If you can't get it to work with one regular expression or you find you want to preserve more comments you could use preg_replace_callback. You can then define a function to handle the comments individually.
/U', 'comment_replace_func', $buffer);
}
function comment_replace_func($m) {
if (preg_match( '/^\<\!--\[if \!/i', $m[0])) {
return $m[0];
}
return '';
}
ob_start("callback");
?>
... HTML source goes here ...