很不错的一个UBB代码

2008-02-23 09:35:04来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

<%
Function HTMLEncode(ByVal strValue)
'忽略错误
On Error Resume Next
'定义变量
Dim strNewValue
If strValue <> "" Then
strNewValue = Replace(strValue,"<","&lt;")
strNewValue = Replace(strNewValue,">","&gt;")
strNewValue = Replace(strNewValue,"'","&#39;")
strNewValue = Replace(strNewValue,"""","&quot;")
strNewValue = Replace(strNewValue,vbCrLf,"<br>")
strNewValue = Replace(strNewValue," ","&nbsp;")
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=""http://download.macromedia.com/pub/sho ... h/swflash.cab#version=4,0,2,0"" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400 id=ShockwaveFlash1><PARAM NAME=movie VALUE=""$2""><PARAM NAME=quality VALUE=high><embed src=""$2"" quality=high pluginspage=""") ' target=_blank>http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""appl ... 00 height=400></embed></OBJECT>")

RegExp.Pattern="(\[ZIP\])(.[^\[]*)(\[\/ZIP\])"
strValue=RegExp.Replace(strValue,"<br><a href=""$2"">点击下载该文件</a>")

RegExp.Pattern="(\[RAR\])(.[^\[]*)(\[\/RAR\])"
strValue=RegExp.Replace(strValue,"<br><a href=""$2"">点击下载该文件</a>")

'RegExp.Pattern="(\[UPLOAD=(.[^\[]*)\])(.[^\[]*)(\[\/UPLOAD\])"
'strValue=RegExp.Replace(strValue,"<br><IMG SRC=""$2.gif"" border=0> <A HREF=""$3"" TARGET=_blank> 点击查看或下载该文件</A>")
'strValue=RegExp.Replace(strValue,"<br><IMG SRC=""$2.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>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.Pattern = "(ftp://[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.Pattern = "^(rtsp://[A-Za-z0-9\./=\?%\-&_~`@': !] )"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")

RegExp.Pattern = "(rtsp://[A-Za-z0-9\./=\?%\-&_~`@': !] )$"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")

RegExp.Pattern = "[^>=""](rtsp://[A-Za-z0-9\.\/=\?%\-&_~`@': !] )"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")

RegExp.Pattern = "^(mms://[A-Za-z0-9\./=\?%\-&_~`@': !] )"
strValue=RegExp.Replace(strValue,"<a target=_blank href=$1>$1</a>")

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:asp编写的加密和解密类

下一篇:正则表达式简介