我在<srcipt runat=server>加入下列代码
Function UBBCode(strContent as string) as string
If isnothing(strContent) Or isdbNull(strContent) Then
        Exit Function
Else
strContent=Replace(strContent,"[#seperator#]","")
Dim re, strMatches, strMatch, tmpStr1, tmpStr2, tmpStr3, tmpStr4, RNDStr
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="\[code\](<br>)+"
strContent=re.Replace(strContent,"[code]")
re.Pattern="\[quote\](<br>)+"
strContent=re.Replace(strContent,"
Quote:
")
re.Pattern="([^=\]][\s]*?|^)(https?|ftp|gopher|news|telnet|mms|rtsp)://([a-z0-9/\-_+=.~!%@?#%&;:$\\()|]+)"
StrContent=re.Replace(StrContent,"$1$2://$3")
re.Pattern="\[img\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=CheckLinkStr(strMatch.SubMatches(0))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr1&""" border=""0"" onload=""javascript:DrawImage(this);"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
Set strMatches=Nothing
re.Pattern="\[img=(left|right|center|absmiddle)\](.*?)\[\/img\]"
Set strMatches=re.Execute(strContent)
For Each strMatch In strMatches
tmpStr1=strMatch.SubMatches(0)
tmpStr2=CheckLinkStr(strMatch.SubMatches(1))
strContent=Replace(strContent,strMatch.Value,"<img src="""&tmpStr2&""" align="""&tmpStr1&"""  onload=""javascript:DrawImage(this);""  border=""0"" alt=""按此在新窗口打开图片"" onmouseover=""this.style.cursor='hand';"" onclick=""window.open(this.src);"" />")
Next
strContent=replace(strContent,"[swf]","[swf=550,400]")
re.Pattern="\[(swf)=(\d*?|),(\d*?|)\](.*?)\[\/(swf)\]"
Set strMatches=re.Execute(strContent)
For Each strMatch in strMatches
RNDStr=Int(7999 * Rnd + 2000)
tmpStr1=CheckLinkStr(strMatch.SubMatches(3))
strContent= Replace(strContent,strMatch.Value,"<table border='0' cellpadding='4' cellspacing='1' style='background: #FFF;color: #666666;margin: 10px;padding: 10px;border: 1px dashed #CCC;'><tr><td><input id=""VOBJ_"&RNDStr&""" type=""hidden"" value=""-1"" /><a href=""javascript:UBBShowObj('"&strMatch.SubMatches(0)&"','OBJ_"&RNDStr&"','"&strMatch.SubMatches(3)&"','"&strMatch.SubMatches(1)&"','"&strMatch.SubMatches(2)&"');""><img src=""/blog/images/icon_flash.gif"" alt=""显示Flash文件"" align=""absmiddle"" border=""0"" /> 点击显示/隐藏Flash文件</a><div id=""OBJ_"&RNDStr&"""></div></td></tr></table>")
Next
Set strMatches=Nothing
strContent=replace(strContent,"[wma]","[wma=300,50]")
strContent=replace(strContent,"[mp3]","[mp3=300,50]")
strContent=replace(strContent,"[mid]","[mid=300,50]")
strContent=replace(strContent,"[ra]","[ra=450,60]")
re.Pattern="\[(wma|mp3|mid|ra)=(\d*?|),(\d*?|)\](.*?)\[\/(wma|mp3|mid|ra)\]"
Set strMatches=re.Execute(strContent)
For Each strMatch in strMatches
RNDStr=Int(7999 * Rnd + 2000)
tmpStr1=CheckLinkStr(strMatch.SubMatches(3))
............
Set re=Nothing
UBBCode=strContent
End IF
End Function但是提示错误BC30807: 'Let' and 'Set' assignment statements are no longer supported
指向Set re=new RegExp请问应该怎么改?

解决方案 »

  1.   

    jolinkyo(心有多大,舞台就有多大)
    非常感谢你,但是我改成
    dim re=new RegExp
    以后提示
    BC30002: Type 'RegExp' is not defined(我已经在页面顶部导入空间<%@ Import Namespace="System.Text.RegularExpressions.Regex" %>)
      

  2.   

    谢谢了,我找到了一段代码
    Function ubbcode(vstr as string) as string
    Dim objregex As Regex
    '''UBB转换
    '''url
    objregex = New Regex("\[url\](http|https|ftp):\/\/(.[^\[]*)\[\/url\]")
    vstr = objregex.Replace(vstr, "<a href=""$1://$2"" TARGET=""_blank"">$1://$2</a>")
    objregex = New Regex("\[URL\](http|https|ftp):\/\/(.[^\[]*)\[\/URL\]")
    vstr = objregex.Replace(vstr, "<a href=""$1://$2"" TARGET=""_blank"">$1://$2</a>")
    '''EMAIL
    objregex = New Regex("(\[email\])(\S+\@.[^\[]*)(\[\/email\])")
    vstr = objregex.Replace(vstr, "<A HREF=""mailto:$2"">$2</A>")
    objregex = New Regex("(\[email=(\S+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])")
    vstr = objregex.Replace(vstr, "<A HREF=""mailto:$2"" TARGET=_blank>$3</A>")
    objregex = New Regex("(\[EMAIL\])(\S+\@.[^\[]*)(\[\/EMAIL\])")
    vstr = objregex.Replace(vstr, "<A HREF=""mailto:$2"">$2</A>")
    objregex = New Regex("(\[email=(\S+\@.[^\[]*)\])(.[^\[]*)(\[\/email\])")
    vstr = objregex.Replace(vstr, "<A HREF=""mailto:$2"" TARGET=_blank>$3</A>")
    '''IMG
    objregex = New Regex("\[img\](http|https|ftp):\/\/(.[^\[]*)\[\/img\]")
    vstr = objregex.Replace(vstr, "<br/><a onfocus=this.blur() href=""$1://$2"" target=_blank><IMG SRC=""$1://$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
    objregex = New Regex("\[IMG\](http|https|ftp):\/\/(.[^\[]*)\[\/IMG\]")
    vstr = objregex.Replace(vstr, "<br/><a onfocus=this.blur() href=""$1://$2"" target=_blank><IMG SRC=""$1://$2"" border=0 alt=按此在新窗口浏览图片 onload=""javascript:if(this.width>screen.width-333)this.width=screen.width-333""></a>")
    '''COLOR
    objregex = New Regex("\[color=(.[^\[]*)\](.[^\[]*)\[\/color\]")
    vstr = objregex.Replace(vstr, "<font color=""$1"">$2</font>")
    objregex = New Regex("\[COLOR=(.[^\[]*)\](.[^\[]*)\[\/COLOR\]")
    vstr = objregex.Replace(vstr, "<font color=""$1"">$2</font>")
    '''u