I use this regexp to find and replace an HTML comment traditionally:
//remove HTML comments
$HTML = preg_replace('/<!--(.|\s)+?-->/','',$HTML);
However, on one server that's apparently crashing (works fine on my VM but it's pretty high powered).
The logic is, start the comment, any character or whitespace (at least some = +), and the ?
means "don't be greedy and stop at the first --> you get"
Is there a better way to write this, esp. the (.|\s)+?
part?