UBB 转换函数演示 (经典论坛)(4)

re=https://www.jb51.net/(\[color=(.[^\[]*)\])(.*?)(\[\/color\])/ig
 strContent=strContent.replace(re,"<font color=https://www.jb51.net/article/$2>$3</font>")
 re=https://www.jb51.net/(\[face=(.[^\[]*)\])(.*?)(\[\/face\])/ig
 strContent=strContent.replace(re,"<font face=https://www.jb51.net/article/$2>$3</font>")
 re=https://www.jb51.net/(\[align=(.[^\[]*)\])(.*?)(\[\/align\])/ig
 strContent=strContent.replace(re,"<div align=https://www.jb51.net/article/$2>$3</div>")
//循环转换quote
 re=https://www.jb51.net/(\[QUOTE\])(.*?)(\[\/QUOTE\])/ig
 while(strContent.indexOf("[quote]")>0 && strContent.indexOf("[/quote] ")>0){
 strContent=strContent.replace(re,"<blockquote>引用:<hr><span>$2</span><hr></blockquote>")
 }
 re=https://www.jb51.net/(\[fly\])(.*?)(\[\/fly\])/ig
 strContent=strContent.replace(re,"<marquee width=90% behavior=alternate scrollamount=3>$2</marquee>")
 re=https://www.jb51.net/(\[move\])(.*?)(\[\/move\])/ig
 strContent=strContent.replace(re,"<MARQUEE scrollamount=3>$2</marquee>") 
 re=https://www.jb51.net/\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*?)\[\/GLOW]/ig
 strContent=strContent.replace(re,"<table width=https://www.jb51.net/article/$1 style=\"filter:glow(color=https://www.jb51.net/article/$2, strength=https://www.jb51.net/article/$3)\">$4</table>")
 re=https://www.jb51.net/\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.*?)\[\/SHADOW]/ig
 strContent=strContent.replace(re,"<table width=https://www.jb51.net/article/$1 style=\"filter:shadow(color=https://www.jb51.net/article/$2, strength=https://www.jb51.net/article/$3)\">$4</table>")

re=https://www.jb51.net/(\[i\])(.*?)(\[\/i\])/ig
 strContent=strContent.replace(re,"<i>$2</i>")
 re=https://www.jb51.net/(\[u\])(.*?)(\[\/u\])/ig
 strContent=strContent.replace(re,"<u>$2</u>")
 re=https://www.jb51.net/(\[b\])(.*?)(\[\/b\])/ig
 strContent=strContent.replace(re,"<b>$2</b>")

re=https://www.jb51.net/(\[size=1\])(.*?)(\[\/size\])/ig
 strContent=strContent.replace(re,"<font size=1>$2</font>")
 re=https://www.jb51.net/(\[size=2\])(.*?)(\[\/size\])/ig
 strContent=strContent.replace(re,"<font size=2>$2</font>")
 re=https://www.jb51.net/(\[size=3\])(.*?)(\[\/size\])/ig
 strContent=strContent.replace(re,"<font size=5>$2</font>")
 re=https://www.jb51.net/(\[size=4\])(.*?)(\[\/size\])/ig
 strContent=strContent.replace(re,"<font size=6>$2</font>")

 re=https://www.jb51.net/\[size=([+|-]?[0-7])\](.*?)(\[\/size\])/ig
 strContent=strContent.replace(re,"<font size=https://www.jb51.net/article/$1>$2</font>")

 re=https://www.jb51.net/(\[list\])(.+?)(\[\/list\])/ig;
    strContent=strContent.replace(re,"<UL TYPE=SQUARE>$2<\/UL>");
    re=https://www.jb51.net/(\[list=)(A|1)(\])(.+?)(\[\/list\])/ig;
    strContent=strContent.replace(re,"<OL TYPE=https://www.jb51.net/article/$2>$4<\/OL>");
    re=https://www.jb51.net/(\[\*\])/ig;
    strContent=strContent.replace(re,"<LI>");

re=https://www.jb51.net/(\[center\])(.*?)(\[\/center\])/ig
 strContent=strContent.replace(re,"<center>$2</center>")

re=https://www.jb51.net/(\[table=(#*[a-z0-9]*),(#*[a-z0-9]*),(#*[a-z0-9]*)\])(.*?)(\[\/table\])/ig
 strContent=strContent.replace(re,"<table border=0 cellpadding=5 cellspacing=1 bgcolor=https://www.jb51.net/article/$2><tr><td bgcolor=https://www.jb51.net/article/$3><font color=https://www.jb51.net/article/$4>$5</font></td></tr></table>")

return(strContent);
}
</script>



vbscript:

复制代码 代码如下:


<style>
.CodeSamp {
 PADDING-RIGHT: 0.5em; MARGIN-TOP: 1em; PADDING-LEFT: 0.5em; FONT-SIZE: 8p; MARGIN-BOTTOM: 1em; PADDING-BOTTOM: 0.5em; MARGIN-LEFT: 0pt; PADDING-TOP: 0.5em; FONT-FAMILY: "Courier New"; BACKGROUND-COLOR: #eeeeee;width: 480px;overflow:hidden;border: 1px solid #888888;
}
textarea {
border-width: 1; border-color: #000000;font-size: 12px;FONT-FAMILY: "Tahoma", "MS Shell Dlg";
}
</style>

<TEXTAREA name=phx cols=65 rows=12>
[i][b][color=blue]blue[/color][/b][/i]

{html}[color=red]te
st[/color]{/html}

{html}[code]te
st[/code]{/html}

[code]{html}te
st{/html}[/code]</textarea>
<br><button onclick=show.innerHTML=UBBCode(phx.value)>转换</button><br>
<div id=show></div>


<script language=vbs>
strIcons = "1"  '允许笑脸转换
strSmile="1"   '同上
ImgName="em"
picurl="pic/"

function UBBCode(content)
'on error resume next
st=timer
set re=new regexp
re.global=true

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzzgd.html