ubb|函数|转换
function ubb2xhtml($ubb) { $flash= codebase="" width="%1\$d" height="%2\$d">@#%\[size=([^\s]+)\](.*?)\[/size\]%s@#, @#%\[align=(center|right|left)\](.*?)\[/align\]%s@#, @#%\[valign=(middle|top|bottom)\](.*?)\[/valign\]%s@#, /* @#%\[ul\](.*?)\[/ul\]%s@#, @#%\[ul=(circle|disc|square)\](.*?)\[/ul\]%s@#, @#%\[ol\](.*?)\[/ol\]%s@#, @#%\[ol type=([aAiI1]) start=([a-zA-Z1-9])\](.*?)\[/ol\]%s@#, @#%\[li\](.*?)\[/li\]%s@#, */ @#%\[table=([^\s]+?)\](.*?)\[/table\]%s@#, @#%\[caption\](.*?)\[/caption\]%s@#, @#%\[tr=([^\s]+?)\](.*?)\[/tr\]%s@#, @#%\[th\](.*?)\[/th\]%s@#, @#%\[td\](.*?)\[/td\]%s@#, @#%\[note\](.*?)\[/note\]%s@#, @#%\[quote=(.*?)\](.*?)\[/quote\]%s@#, @#%\[code\](.*?)\[/code\]%s@#, @#%[ ]{2}%s@#, // make double-spaces truly double-spaces! ); $replace = array ( @#\2 @#, @#\2 @#, @# @#, @# @#, @#sprintf("$flash", "\1", "\2", "\3")@#, @#\2\1>@#, @#
\2
\1>@#, @#
\n@#,
@#
\2 @#,
@#
\2 @#,
@#
\2 @#,
@#
\2@#,
@#
\2@#,
/*
@#
@#,
@#
@#,
@#
\1
@#,
@#
\3
@#,
@#
\1 @#,
*/
"
",
"\t$1\n",
"\t\n$2\t\n",
"\t\t$1\n",
"\t\t$1\n",
@#
发布者备注
\1
@#,
@#
@#,
@#
代码
\1
@#,
@# @#,
);
if( preg_match(@#%\[table=(.*?)\/table\]%s@#, $ubb, $tablecells) ) //如果有表格, 先去除单元格之间的多余空白
{
$bb=preg_replace(@#%\]([\r\n\s]*)\[%si@#, @#][@#, $tablecells[1]);
$ubb=str_replace($tablecells[1], $bb, $ubb);
}
$html = preg_replace($match, $replace, nl2br(htmlspecialchars($ubb)));
$html = preg_replace(@#/
\s* return $html;
}