繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> 脚本编码 >> UBB代码~(整理)

UBB代码~(整理)

2004-10-01 08:26:10  作者:  来源:互联网  浏览次数:105  文字大小:【】【】【
简介:在论坛中,我常常要使用到特殊的显示效果,而要得到这些效果,我们通常都是使用ubb 函数来处理,下面是我整理的ubb代码~,有待完善~ [CODE] '----------------------------------------------------------' '-...
关键字:代码 UBB

在论坛中,我常常要使用到特殊的显示效果,而要得到这些效果,我们通常都是使用ubb 函数来处理,下面是我整理的ubb代码~,有待完善~

[CODE]

'----------------------------------------------------------'

'--------------------UBBCode Function----------------------'

'----------------------------------------------------------'

Function UBBCode(ByVal strValue)

'忽略错误

On Error Resume Next

'定义变量

Dim RegExp

Dim strNewValue

Set RegExp = New RegExp

RegExp.IgnoreCase = True

RegExp.Global = True

strValue = UCase(HTMLEncode(strValue))

If strValue <> "" Then

RegExp.Pattern = "(\[URL\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"$2")

RegExp.Pattern = "(\[URL\])(HTTP:\/\/.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"$2")

RegExp.Pattern = "(\[URL=(HTTP:\/\/.[^\[]*)\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"$3")

RegExp.Pattern = "(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"

strNewValue = RegExp.Replace(strValue,"$3")

RegExp.Pattern = "(\[IMG\])(.[^\[]*)(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"")

RegExp.Pattern = "(\[IMG=(HTTP:\/\/.[^\[]*)\])(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"")

RegExp.Pattern = "(\[IMG=(.[^\[]*)\])(\[\/IMG\])"

strNewValue = RegExp.Replace(strNewValue,"")

RegExp.Pattern = "(\[SIZE=([0-9]*)\])(.[^\[]*)(\[\/SIZE\])"

strNewValue = RegExp.Replace(strNewValue,"$3")

RegExp.Pattern = "(\[B\])(.[^\[]*)(\[\/B\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[COLOR=(.[^\[]*)\])(.[^\[]*)(\[\/RED\])"

strNewValue = RegExp.Replace(strNewValue,"$3")

RegExp.Pattern = "(\[RED\])(.[^\[]*)(\[\/RED\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[GREEN\])(.[^\[]*)(\[\/GREEN\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[BLUE\])(.[^\[]*)(\[\/BLUE\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[GRAY\])(.[^\[]*)(\[\/GRAY\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[S\])(.[^\[]*)(\[\/S\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[I\])(.[^\[]*)(\[\/I\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[U\])(.[^\[]*)(\[\/U\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[ALIGN=(.[^\[]*)\])(.[^\[]*)(\[\/ALIGN\])"

strNewValue = RegExp.Replace(strNewValue,"

$3
")

RegExp.Pattern = "(\[CENTER\])(.[^\[]*)(\[\/CENTER\])"

strNewValue = RegExp.Replace(strNewValue,"

$2
")

RegExp.Pattern = "(\[EMAIL\])(.[^\[]*)(\[\/EMAIL\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[EMAIL=(.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"

strNewValue = RegExp.Replace(strNewValue,"$3")

RegExp.Pattern = "(\[FLY\])(.[^\[]*)(\[\/FLY\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[MOVE\])(.[^\[]*)(\[\/MOVE\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[MP=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/MP\])"

strNewValue = RegExp.Replace(strNewValue,"")

RegExp.Pattern = "(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"

strNewValue = RegExp.Replace(strNewValue,"$2")

RegExp.Pattern = "(\[QT=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/QT\])"

strNewValue = RegExp.Replace(strNewValue,"")

RegExp.Pattern = "(\[RM=([0-9]*),([0-9]*)\])(.[^\[]*)(\[\/RM\])"

strNewValue = RegExp.Replace(strNewValue,"
")

End If

UBBCode = LCase(strNewValue)

'输出错误

If Err.Number>0 Then

Response.Write Err.Description

Response.End

End If

End Function

'----------------------------------------------------------'

'-------------------HTMLEncode Function--------------------'

'----------------------------------------------------------'

Function HTMLEncode(ByVal strValue)

'忽略错误

On Error Resume Next

'定义变量

Dim strNewValue

If strValue <> "" Then

strValue = Server.HTMLEncode(strValue)

strNewValue = Replace(strValue,"<","<")

strNewValue = Replace(strNewValue,">",">")

strNewValue = Replace(strNewValue,"'","'")

strNewValue = Replace(strNewValue,"""",""")

strNewValue = Replace(strNewValue,vbCrLf,"
")

strNewValue = Replace(strNewValue," "," ")

End If

HTMLEncode = strNewValue

'输出错误

If Err.Number>0 Then

Response.Write Err.Description

Response.End

End If

End Function

[CODE]

使用的时候,在你的textarea中输入ubb代码,那么,在处理页面直接使用

content = UBBCode(Request.Form("content"))就可以咯~

关于ubb的书写,可以在网上搜索,我就不说咯!

责任编辑:admin
相关文章