Question

How do I preg_replace this pattern: <!--[if gte mso 9]&gt;-->

This is my full code:

$content = preg_replace("/<!--[if gte mso 9]&gt;-->/", "", $content);
Was it helpful?

Solution

Square brackets have a special meaning in regular expressions, so you need to escape them:

$content = preg_replace("/<!--\[if gte mso 9\]&gt;-->/", "", $content);

NB: as you are doing a simple replace without regex, this will be faster:

`$content = str_replace("<!--[if gte mso 9]&gt;-->", "", $content);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top