<p >记录下js处理ubb代码的方法:</p><ol class=" list-paddingleft-2"><li><p>String.prototype.UBB=function()<br/>{<br/>varstr=this;<br/>str=str.replace(/[br]/ig,"<br/>");/*回车*/<br/>str=str.replace(/[u](.+?)[/u]/ig,"<u>$1</u>");/*下划线*/<br/>str=str.replace(/[i](.+?)[/i]/ig,"<i>$1</i>");/*斜体*/<br/>str=str.replace(/[b](.+?)[/b]/ig,"<b>$1</b>");/*粗体*/<br/>str=str.replace(/[QUOTE](.+?)[/QUOTE]/ig,"<BLOCKQUOTE><fontsize=2face="Verdana,Arial">引用:</font><HR>$1<HR></BLOCKQUOTE>");/*引用*/<br/>str=str.replace(/[red](.+?)[/red]/ig,"<FONTCOLOR="#ff0000">$1</FONT>");/*红色字*/<br/>str=str.replace(/[gray](.+?)[/gray]/ig,"<FONTCOLOR="#77ACAC">$1</FONT>");/*灰色字*/<br/>str=str.replace(/[green](.+?)[/green]/ig,"<FONTCOLOR="#77ACAC">$1</FONT>");/*绿色字*/<br/>str=str.replace(/[blue](.+?)[/blue]/ig,"<FONTCOLOR="#0055ff">$1</FONT>");/*蓝色字*/<br/>str=str.replace(/[color=(.+?)](.+?)[/color]/ig,"<FONTCOLOR="$1">$2</FONT>");/*任何颜色*/<br/>str=str.replace(/[EMAIL](S+@S+?)[/EMAIL]/ig,"<AHREF="mailto:$1">$1</A>");/*邮件*/<br/>str=str.replace(/[URL](http://S+?)[/URL]/ig,"<AHREF="$1"TARGET=_blank>$1</A>");/*链接http://*/<br/>str=str.replace(/[URL](S+?)[/URL]/ig,"<AHREF="http://$1"TARGET=_blank>$1</A>");/*链接*/<br/>str=str.replace(/[marquee](.+?)[/marquee]/ig,"<marqueescrollamount="3"onmouseover="javascript:this.stop()"onmouseout="javascript:this.start()">$1</marquee>");/*滚动*/<br/>str=str.replace(/[IMGurl=(http://S+?)](http://S+?)[/IMGurl]/ig,"<ahref="$1"target=_blank><IMGSRC="$2"border=0onload="javascript:if(this.width>screen.width-366)this.width=screen.width-366"/></a>");/*带图片链接http://*/<br/>str=str.replace(/[IMGurl=(S+?)](S+?)[/IMGurl]/ig,"<ahref="http://$1"target=_blank><IMGSRC="http://$2"border=0onload="javascript:if(this.width>screen.width-366)this.width=screen.width-366"/></a>");/*带图片链接*/<br/>str=str.replace(/[IMG](S+?)[/IMG]/ig,"<IMGSRC="$1"/>");/*图片*/<br/>returnstr;<br/>}</p></li></ol><p >使用时就直接</p><ol class=" list-paddingleft-2"><li><p>str=str.UBB();</p></li></ol>