function ubb2html(str)
{
var i=0 ,codes=[], s=''+str, split_str='', tqeUrl='http://www.qs.com/vt/inc/client/js/tqEditor/',
escUrl=function(url){return url.replace(/\[\]/g, function(c){return {'[':'%5b',']':'%5d'}[c];})};//TQE.url;
s=s.replace(/[<>\" ]/g,function(c){return {'<':'<','>':'>','"':'"',' ':' '}[c];} ).replace(/\r?\n/g, '
');
do{split_str= '__CODE__'+Math.random()+'_';}while(s.indexOf(split_str)>=0);
s = s.replace(/\[code[=\]].*?\[\/code\]/ig, function(cs){codes.push(cs); return split_str+(i++)+'_'})
.replace(/\[flv(?:\s*=\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+)\s*)?)?\](.*?)\[\/flv\]/ig, function(all,w,h,auto_start,url){
if(!w) w=320;
if(!h) h=240;
return ''})
.replace(/\[rm(?:\s*=\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+)\s*)?)?\](.*?)\[\/rm\]/ig, function(all,w,h,auto_start,url){
if(!w) w=320;
if(!h) h=240;
return '';})
.replace(/\[mp3\](.*?)\[\/mp3\]/ig, '')
.replace(/\[img\](.*?)\[\/img\]/ig, '
')
.replace(/\[img(?:=\s*(\d+)\s*,\s*(\d+)\s*)\]\s*([\w_\-\.\/:]*)\s*\[\/img\]/ig, '
')
.replace(/\[(color|size)\s*=\s*([^\]]+)\s*\]/ig, '').replace(/\[\/(color|size)\]/ig, '')
.replace(/\[bg\s*=\s*([^\]]+)\s*\]/ig, '').replace(/\[\/bg]/ig, '')
.replace(/\[(left|center|right)]/ig, '
').replace(/\[\/(left|center|right)]/ig, '
')
.replace(/(?:
|\s)?\[list\](.*?)(
|\s)*\[\/list\]/ig, function(a,c){ return ''+c.replace(/\
(\s| )*\[\*\]/g, '- ')+'
';})
.replace(/(?:
|\s)?\[numlist\](.*?)(
|\s)*\[\/numlist\]/ig, function(a,c){ return ''+c.replace(/\
(\s| )*\[\*\]/g, '- ')+'
';})
.replace(/\[\:(\d+)]/g, '
') //表情
.replace(/\[(\/?(?:b|u|i|s|sup|sub|h[1-6]))\]/ig, '<$1>')
.replace(/\[url\]\s*(((?!")[\s\S])*?)(?:"[\s\S]*?)?\s*\[\/url\]/ig,'$1')
.replace(/\[url\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]*?)\s*\[\/url\]/ig,'$2')
.replace(/\[email\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/email\]/ig,'$1')
.replace(/\[email\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]+?)\s*\[\/email\]/ig,'$2')
.replace(/\[qq\]\s*(\d+)\s*\[\/qq\]/ig,'$1')
.replace(/\[qq\s*=\s*(\d+)\s*\]\s*([\s\S]+?)\s*\[\/qq\]/ig,'$2')
.replace(/\[quote\]([\s\S]*?)\[\/quote\]/ig,'$1
');
while(/\[table\](((?!\[table)[\s\S])+?)\[\/table\]/i.test(s)){
s=s.replace(/\[table\](((?!\[table)[\s\S])+?)\[\/table\]/ig, function(a,c){
return ''+c.replace(/\[(\/?(?:tr|td|th))\]/ig, '<$1>')+'
';
});
}
i=-1;
s= s.replace(new RegExp(split_str+'\\d+_','g'), function(c){return codes[++i];});
return s;
}
function html2ubb(str)
{
var i=0 ,codes=[], s=''+str, split_str='';
do{split_str= '__CODE__'+Math.random()+'_';}while(s.indexOf(split_str)>=0);
s = s.replace(/[\r\n]/g,'').replace(/
]*>/ig,"\n");
s = s.replace(/\[code[=\]].*?\[\/code\]/ig, function(cs){codes.push(cs); return split_str+(i++)+'_'})
.replace(/