PHP实现HTML代码转UBB标签
$text = str_replace("/\r/g","",$text);
$text = str_replace("/on(load|click|dbclick|mouseover|mousedown|mouseup)=[^]+/ig","",$text);
$text = str_replace("/<script[^>]*?>([\w\W]*?)<\/script>/ig","",$text);
$text = str_replace("/<a[^>]+href=([^]+)[^>]*>(.*?)<\/a>/ig","[url=$1]$2[/url]",$text);
$text = str_replace("/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig","[color=$1]$2[/color]",$text);
$text = preg_replace("/\<img[^>]+src=\"([^\"]+)\"[^>]*\>/i","[img]$1[/img]\n",$text);
$text = preg_replace("/\<font(.*?)face=\"([^ >]+)\"(.*?)\>(.*?)<\/font>/i","<font$1$3>[face=$2]$4[/face]</font>",$text);
$text = preg_replace("/\<font(.*?)size=\"([^ >]+)\"(.*?)\>(.*?)<\/font>/i","[size=$2]$4",$text);
$text = preg_replace("/\<DIV[^>]+ALIGN=\"([^\"]+)\"[^>]*\>(.*?)<\/DIV\>/i","[align=$1]$2",$text);
$text = preg_replace("/\<([\/]?)em\>/i","[$1I]",$text);
$text = str_replace("/<([\/]?)b>/ig","[$1b]",$text);
$text = str_replace("/<([\/]?)strong>/ig","[$1b]",$text);
$text = str_replace("/<([\/]?)u>/ig","[$1u]",$text);
$text = str_replace("/<([\/]?)i>/ig","[$1i]",$text);
$text = str_replace("/ /g"," ",$text);
$text = str_replace("/&/g","&",$text);
$text = str_replace("/</g","<",$text);
$text = str_replace("/>/g",">",$text);
$text = str_replace("/<br>/ig","\n",$text);
$text = str_replace("<br />","\n",$text);
$text = str_replace("<P>","",$text);
$text = str_replace("</P>","",$text);
$text = str_replace("/<[^>]*?>/g","",$text);
$text = str_replace("/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g","$2",$text);
$text = str_replace("/\n+/g","\n",$text);
$text = preg_replace( "@<script(.*?)</script>@is", "", $text );
$text = preg_replace( "@<iframe(.*?)</iframe>@is", "", $text );
$text = preg_replace( "@<style(.*?)</style>@is", "", $text );
$text = preg_replace( "@<(.*?)>@is", "", $text );[/code]