鉴于大家对ASP十分关注,我们编辑小组在此为大家搜集整理了“很不错的一个UBB代码”一文,供大家参考学习
<%
Function HTMLEncode(ByVal strValue)
''忽略错误
On Error Resume Next
''定义变量
Dim strNewValue
If strValue <> "" Then
strNewValue = Replace(strValue,"<","<")
strNewValue = Replace(strNewValue,">",">")
strNewValue = Replace(strNewValue,"''","'")
strNewValue = Replace(strNewValue,"""",""")
strNewValue = Replace(strNewValue,
vbCrLf,"<br>")
strNewValue = Replace(strNewValue," "," ")
End If
HTMLEncode = strNewValue
''输出错误
If Err.Number>0 Then
Response.Write Err.Description
Response.End
End If
End Function
Function UBBCode(strValue)
Dim RegExp
''strValue=HTMLEncode(strValue)
Set RegExp=New RegExp
RegExp.IgnoreCase =True
RegExp.Global=True
If strValue <> "" Then
RegExp.Pattern="(\[IMG\])(.[^\[]*)(\[\/IMG\])"
strValue=RegExp.Replace(strValue,"<a href=""$2"" target=_blank><IMG SRC=""$2"" border=0 alt=按此在新窗口浏览
图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
RegExp.Pattern="(\[FLASH\])(.[^\[]*)(\[\/FLASH\])"
strValue=RegExp.Replace(strValue,"<OBJECT codebase=""/uploadfile/201306/17/3C155337928.gif"" border=0> <A HREF=""$3"" TARGET=_blank>点击查看或
下载该文件</A>")
''strValue=RegExp.Replace(strValue,"<br><IMG SRC=""/uploadfile/201306/17/1B155338864.gif"" border=0>此主题相关图片如下:<br><A HREF=""$3"" TARGET=_blank><IMG SRC=""$3"" border=0 alt=按此在新窗口浏览
图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></A>")
RegExp.Pattern="(\[URL\])(http:\/\/.[^\[]*)(\[\/URL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""$2"" TARGET=_blank>$2</A>")
RegExp.Pattern="(\[URL\])(.[^\[]*)(\[\/URL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""$2") '' target=_blank rel=nofollow>http://$2"" TARGET= ... t;/A>")
RegExp.Pattern="(\*)\])(.[^\[]*)(\[\/URL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""$2"" TARGET=_blank>$3</A>")
RegExp.Pattern="(\[URL=(.[^\[]*)\])(.[^\[]*)(\[\/URL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""[url]http://$2"" TARGET=_blank>$3</A>")
RegExp.Pattern="(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""mailto:$2"">$2</A>")
RegExp.Pattern="(\[EMAIL=(\S+\@.[^\[]*)\])(.[^\[]*)(\[\/EMAIL\])"
strValue=RegExp.Replace(strValue,"<A HREF=""mailto:$2"" TARGET=_blank>$3</A>")
RegExp.Pattern = "^(http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")
RegExp.Pattern = "(http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)$"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")
RegExp.Pattern = "[^>=""](http://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")
RegExp.Pattern = "^(ftp://[A-Za-z0-9\./=\?%\-&_~`@'':+!]+)"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")
RegExp.P