String.prototype.UBB=function()
{
var str=this;
str=str.replace(/\[br\]/ig,"<br/>");/*回车*/
str=str.replace(/\[u\](.+?)\[\/u\]/ig,"<u>$1</u>");/*下划线*/
str=str.replace(/\[i\](.+?)\[\/i\]/ig,"<i>$1</i>");/*斜体*/
str=str.replace(/\[b\](.+?)\[\/b\]/ig,"<b>$1</b>");/*粗体*/
str=str.replace(/\[QUOTE\](.+?)\[\/QUOTE\]/ig,"<BLOCKQUOTE><font size=2 face=\"Verdana, Arial\">引用:</font><HR>$1<HR></BLOCKQUOTE>");/*引用*/
str=str.replace(/\[red\](.+?)\[\/red\]/ig,"<FONT COLOR=\"#ff0000\">$1</FONT>");/*红色字*/
str=str.replace(/\[gray\](.+?)\[\/gray\]/ig,"<FONT COLOR=\"#77ACAC\">$1</FONT>");/*灰色字*/
str=str.replace(/\[green\](.+?)\[\/green\]/ig,"<FONT COLOR=\"#77ACAC\">$1</FONT>");/*绿色字*/
str=str.replace(/\[blue\](.+?)\[\/blue\]/ig,"<FONT COLOR=\"#0055ff\">$1</FONT>");/*蓝色字*/
str=str.replace(/\[color\=(.+?)\](.+?)\[\/color\]/ig,"<FONT COLOR=\"$1\">$2</FONT>");/*任何颜色*/
str=str.replace(/\[EMAIL\](\S+\@\S+?)\[\/EMAIL\]/ig,"<A HREF=\"mailto:$1\">$1</A>");/*邮件*/
str=str.replace(/\[URL\](http:\/\/\S+?)\[\/URL\]/ig,"<A HREF=\"$1\" TARGET=_blank>$1</A>");/*链接http://*/
str=str.replace(/\[URL\](\S+?)\[\/URL\]/ig,"<A HREF=\"http://$1\" TARGET=_blank>$1</A>");/*链接*/
str=str.replace(/\[marquee\](.+?)\[\/marquee\]/ig,"<marquee scrollamount=\"3\" onmouseover=\"javascript:this.stop()\" onmouseout=\"javascript:this.start()\">$1</marquee>");/*滚动*/
str=str.replace(/\[IMGurl\=(http:\/\/\S+?)\](http:\/\/\S+?)\[\/IMGurl\]/ig,"<a href=\"$1\" target=_blank><IMG SRC=\"$2\" border=0 onload=\"javascript:if(this.width>screen.width-366)this.width=screen.width-366\"/></a>");/*带图片链接http://*/
str=str.replace(/\[IMGurl\=(\S+?)\](\S+?)\[\/IMGurl\]/ig,"<a href=\"http://$1\" target=_blank><IMG SRC=\"http://$2\" border=0 onload=\"javascript:if(this.width>screen.width-366)this.width=screen.width-366\"/></a>");/*带图片链接*/
str=str.replace(/\[IMG\](\S+?)\[\/IMG\]/ig,"<IMG SRC=\"$1\"/>");/*图片*/
return str;
}使用时就直接
str = str.UBB();就可以了