PHP preg_replace to remove MS Office style html comments -


MS Office style HTML comments, and exploring how to extract everything in the middle I are of this form:

& lt ;! - [if gte mso 10] & gt;

BubbleBlobalBlobalBall

& lt ;; [Endif] - & gt;

or

& lt ;! - [if gte mso 9]> gt;

Blumberball Blobber

and <; [Endif] - & gt;

The problem is facing that I do not want to remove all the comments from Html only these MSO style comments any thoughts?

Try it

  preg_replace ('/ & lt;! - \ s * \ [if [^ \]] *]>. *? & Lt ;! \ [Andif \] - & gt; / i ',' ', $ string);  

All this & lt ;! - [if ...] & gt; .... & lt ;! [Endif] - & gt; will remove comments!


Comments