如何通过正则表达式移除UBB符号?
原始:[p]AK47乐队 [/p][p]20 [/p][color]演出时间:2009年6月7日晚八点半 [/p][p]演出地点:梦旅人音乐客栈 [/p][p]淘宝预售:http://item.taobao.com/auction/item_detail.jhtml?item_id=96430f865be5c244d92c721bcc6f9829&x_id=0db1 [/p]
结果:AK47乐队 20演出时间:2009年6月7日晚八点半演出地点:梦旅人音乐客栈淘宝预售:
原始:[p]AK47乐队 [/p][p]20 [/p][color]演出时间:2009年6月7日晚八点半 [/p][p]演出地点:梦旅人音乐客栈 [/p][p]淘宝预售:http://item.taobao.com/auction/item_detail.jhtml?item_id=96430f865be5c244d92c721bcc6f9829&x_id=0db1 [/p]
结果:AK47乐队 20演出时间:2009年6月7日晚八点半演出地点:梦旅人音乐客栈淘宝预售:
$message = preg_replace("/\[url(=((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|ed2k|thunder|synacast){1}:\/\/|www\.)([^\[\"']+?))?\](.+?)\[\/url\]/ies", "parseurl('\\1', '\\5')", $message);
}
if(stripos($message, '[/email]') !== FALSE) {
$message = preg_replace("/\[email(=([a-z0-9\-_.+]+)@([a-z0-9\-_]+[.][a-z0-9\-_.]+))?\](.+?)\[\/email\]/ies", "parseemail('\\1', '\\4')", $message);
}
$message = str_replace(array(
'[/color]', '[/size]', '[/font]', '[/align]', '', '',
'', '', '', '', '[list]', '[list=1]', '[list=a]',
'[list=A]', '[*]', '[/list]', '[indent]', '[/indent]', '[/float]'
), array(
'</font>', '</font>', '</font>', '</p>', '<strong>', '</strong>', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ul type="1">', '<ul type="a">',
'<ul type="A">', '<li>', '</ul>', '<blockquote>', '</blockquote>', '</span>'
), preg_replace(array(
"/\[color=([#\w]+?)\]/i",
"/\[size=(\d+?)\]/i",
"/\[size=(\d+(\.\d+)?(px|pt|in|cm|mm|pc|em|ex|%)+?)\]/i",
"/\[font=([^\[\<]+?)\]/i",
"/\[align=(left|center|right)\]/i",
"/\[float=(left|right)\]/i" ), array(
"<font color=\"\\1\">",
"<font size=\"\\1\">",
"<font style=\"font-size: \\1\">",
"<font face=\"\\1 \">",
"<p align=\"\\1\">",
"<span style=\"float: \\1;\">"
), $message));
$nest = 0;
while(stripos($message, '[table') !== FALSE && stripos($message, '[/table]') !== FALSE){
$message = preg_replace("/\[table(?:=(\d{1,4}%?)(?:,([\(\)%,#\w ]+))?)?\]\s*(.+?)\s*\[\/table\]/ies", "parsetable('\\1', '\\2', '\\3')", $message);
if(++$nest > 4) break;
} if($parsetype != 1) { // 121416 - phpbb style quote
//一次性查找需要替换的次数,可提高效率
$count1 = substr_count(strtolower($message),'[quote=');
for($i=0;$i<$count1;$i++){
$message = preg_replace("/\s*\
string output = Regex.Replace(str,@"\[[/\w]+\]","");
// AK47乐队 20 演出时间:2009年6月7日晚八点半 演出地点:梦旅人音乐客栈 淘宝预售:http://item.taobao.com/auction/item_detail.jhtml?item_id=96430f865be5c244d92c721bcc6f9829&x_id=0db1
string output = Regex.Replace(str,@"\[[^\]]+\]","");