Апрель 16, 2007 at 12:25
· Размещено в Программирование, PHP, Регулярные выражения
Code (php)
-
-
function wordClean($textbody, $fonts=0) {
-
$textbody =
preg_replace("/[ ]*class=\"?[a-zA-Z0-9]+\"?/Si",
”,
$textbody);
-
$textbody =
preg_replace("/[ ]*style=\"?[^>]*\"?/Si",
”,
$textbody);
-
if ($fonts!=1) {
-
$textbody =
preg_replace("/<font[^>]*(color=\"?[#0-9a-zA-Z]+\"?)[^>]*>/Si",
"<font~~ \\1>",
$textbody);
-
$textbody =
preg_replace("/<\/?font[^>~]*>/Smi",
”,
$textbody);
-
-
}
-
-
-
$textbody =
preg_replace("/<\/?span[^>]*>/Si",
”,
$textbody);
-
$textbody =
preg_replace("/<[^>]xml[^>]*\/>/Si",
”,
$textbody);
-
$textbody =
preg_replace("/<o:p>[^>]*<\/o:p>/Si",
”,
$textbody);
-
$textbody =
preg_replace("/<p(\s|\n)*>/Si",
‘<p>’,
$textbody);
-
$textbody =
preg_replace("/<([a-zA-Z0-9]+)([ \n\r])+([^>]*)>/Si",
"<\\1 \\3>",
$textbody);
-
$textbody =
preg_replace("/[ ](width|height)(=)([0-9]+%?)/Si",
"",
$textbody);
-
$textbody =
preg_replace("/<(p|b|u|i|strong)>\s*<\/(p|b|u|i|strong)>/Si",
”,
$textbody);
-
$textbody =
preg_replace("/<\/(b|u|i|strong)>\s*<(b|u|i|strong)>/Si",
”,
$textbody);
-
-
-
-
$textbody =
preg_replace("/(td[^>]*>[^<]*)(<h[0-9]+>)(.*)(<\/h[0-9]+>)([\n\r]*)(<p>)?(.*<\/td>)/sSi",
"\\1<b>\\3</b>
-
\\7",$textbody);
-
$textbody =
preg_replace("/(<td[^>]*>.*)(<p>)(.*<\/td>)/iSs",
"\\1\\3",
$textbody);
-
-
[\n\r]+<\/td>/iS","</td>",$textbody);
-
return $textbody;
-
}
-
Постоянная ссылка

Загрузка...