12Sep/110
Remove MS Word formatting using PHP regular expressions
Recently i've had a client which would only paste into the CMS text from MS Word. Normally a JS should have been in place to automatically strip the crazy tags Word adds, but on this project this was not the case. Here's hos to remove MS Word formatting using PHP regular expressions:
// it will remove all <!--[if ...]>....<![endif]--> comments
preg_replace('/<!--\[if[^\]]*]>.*?<!\[endif\]-->/i', '', $string);
or
// it will remove all <!--[if ...]>.... --> comments
preg_replace('/<!--\[if[^\]]*]>.*?-->/i', '', $string);