主题:【[推荐]】发帖的时候ubb代码
命名空间ImportsSystem.Text.RegularExpressions
++++++++++++++++++
Functionubb(ByValvstrAsString)
'替换HTML标记及换行处理 vstr=Server.HtmlEncode(vstr) vstr=Replace(vstr,Chr(32),"") vstr=Replace(vstr,vbCrLf," ")
DimxfaceAsInteger Ifxface=1Then '表情转换,数值型变量xface=1时,允许转换 vstr=Replace(vstr,":)","") vstr=Replace(vstr,":(","") vstr=Replace(vstr,":o","") vstr=Replace(vstr,":D","") vstr=Replace(vstr,";)","") vstr=Replace(vstr,":p","") vstr=Replace(vstr,":cool:","") vstr=Replace(vstr,":mad:","") vstr=Replace(vstr,":eek:","") vstr=Replace(vstr,":?:","") EndIf
DimobjregexAsRegex
'屏蔽JS等等 objregex=NewRegex("javascript") vstr=objregex.Replace(vstr,"javascript") objregex=NewRegex("jscript:") vstr=objregex.Replace(vstr,"jscript:") objregex=NewRegex("js:") vstr=objregex.Replace(vstr,"js:") objregex=NewRegex("value") vstr=objregex.Replace(vstr,"value") objregex=NewRegex("about:") vstr=objregex.Replace(vstr,"about:") objregex=NewRegex("file:") vstr=objregex.Replace(vstr,"file:") objregex=NewRegex("document.cookie") vstr=objregex.Replace(vstr,"documents.cookie") objregex=NewRegex("vbscript:") vstr=objregex.Replace(vstr,"vbscript:") objregex=NewRegex("vbs:") vstr=objregex.Replace(vstr,"vbs:") objregex=NewRegex("(on(mouse|exit|error|click|key))") vstr=objregex.Replace(vstr,"on$2") objregex=NewRegex("script") vstr=objregex.Replace(vstr,"script")
'UBB转换 'url objregex=NewRegex("\[url\](http|https|ftp):\/\/(.[^\[]*)\[\/url\]") vstr=objregex.Replace(vstr,"$1://$2") 'EMAIL objregex=NewRegex("(\[email\])(\S+\@.[^\[]*)(\[\/email\])") vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("(\[email=(\S+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])") vstr=objregex.Replace(vstr,"$3")
'IMG objregex=NewRegex("\[img\](http|https|ftp):\/\/(.[^\[]*)\[\/img\]") vstr=objregex.Replace(vstr," screen.width-333)this.width=screen.width-333"">")
'COLOR objregex=NewRegex("\[color=(.[^\[]*)\](.[^\[]*)\[\/color\]") vstr=objregex.Replace(vstr,"$2") 'u objregex=NewRegex("\[u\](.*)\[\/u\]") vstr=objregex.Replace(vstr,"$1") 'B objregex=NewRegex("\[b\](.*)\[\/b\]") vstr=objregex.Replace(vstr,"$1") 'I objregex=NewRegex("\[i\](.*)\[\/i\]") vstr=objregex.Replace(vstr,"$1") 'FLY objregex=NewRegex("\[fly\](.*)\[\/fly\]") vstr=objregex.Replace(vstr,"$1") 'SHADOW objregex=NewRegex("\[shadow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/shadow]") vstr=objregex.Replace(vstr,"
$4 |
")
'CODE objregex=NewRegex("\[code\](.*)\[\/code\]") vstr=objregex.Replace(vstr,"
|
$1 |
")
'glow
objregex=NewRegex("\[glow=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/glow]")
vstr=objregex.Replace(vstr,"
$4")
'move
objregex=NewRegex("(\[move\])(.*)(\[\/move\])")
vstr=objregex.Replace(vstr,"$2")
'center
objregex=NewRegex("(\[center\])(.[^\[]*)(\[\/center\])")
vstr=objregex.Replace(vstr,"
$2")
'flash
objregex=NewRegex("(\[flash\])(.[^\[]*)(\[\/flash\])")
vstr=objregex.Replace(vstr,"
$2")
'quote
objregex=NewRegex("(\[quote\])(.*)(\[\/quote\])")
vstr=objregex.Replace(vstr,"
$2
")
'html
objregex=NewRegex("(\[html\])(.[^\[]*)(\[\/html\])")
vstr=objregex.Replace(vstr,"
以下内容为程序代码:
$2
")
'face
objregex=NewRegex("(\[face=(.[^\[]*)\])(.[^\[]*)(\[\/face\])")
vstr=objregex.Replace(vstr,"$3")
'size
objregex=NewRegex("(\[size=1\])(.[^\[]*)(\[\/size\])")
vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("(\[size=2\])(.[^\[]*)(\[\/size\])")
vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("(\[size=3\])(.[^\[]*)(\[\/size\])")
vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("(\[size=4\])(.[^\[]*)(\[\/size\])")
vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("(\[size=5\])(.[^\[]*)(\[\/size\])")
vstr=objregex.Replace(vstr,"$2")
'自动识别URL
objregex=NewRegex("\[url=(http:\/\/.[^\[]*)\](.[^\[]*)(\[\/url\])")
vstr=objregex.Replace(vstr,"$2")
objregex=NewRegex("^(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)")
vstr=objregex.Replace(vstr,"$1")
objregex=NewRegex("(http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)$")
vstr=objregex.Replace(vstr,"$1")
objregex=NewRegex("[^>=""](http://[A-Za-z0-9\./=\?%\-&_~`@':+!]+)")
vstr=objregex.Replace(vstr,"$1")
'完成,还可以自己扩展
ubb=vstr
EndFunction