tags:

views:

35

answers:

2

I found this function to clean MS Word markup:

$html = ereg_replace("<(/)?(font|span|del|ins)[^>]*>","",$html);
$html = ereg_replace("<([^>]*)(class|lang|style|size|face)=(\"[^\"]*\"|'[^']*'|[^>]+)([^>]*)>","<\\1>",$html);
$html = ereg_replace("<([^>]*)(class|lang|style|size|face)=(\"[^\"]*\"|'[^']*'|[^>]+)([^>]*)>","<\\1>",$html);

and it works fine. However, I would like to replace ereg_replace (deprecated) by preg_replace. When I do this (with / delimiters), the function doesn't work anymore.

I understand very little of regular expressions, I'm afraid... Some wizard here that can help me with this? It would be very much appreciated!!

+2  A: 

Try using # as delimiter, example:

$html = preg_replace("#<(/)?(font|span|del|ins)[^>]*>#","",$html);
Sarfraz
A: 

Thanks a million! That did the trick....

(1) You can leave a comment in your own question. (2) If you find sAc's answer solves your problem, [please accept it](http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work/5235#5235).
KennyTM