ASP高亮类(2)
Dim Temp
If VBCode="" Then
MakeLi=""
Exit Function
End If
VBCode=HTMLEncode(VBCode)
Temp=M_Replace(VBCode,"\b("&Keyword&")\b",KeyWordColor)
Temp=M_Replace(Temp,"\b("&ObjEctCommand&")\b",ObjectCommandColor)
Temp=String_Replace(Temp,"""(.*?)""","""(.*)(<.+?>)("&KeyWord&ObjectCommand&")+(<.+?>)(.*)""",StringsColor,1)'' 字符串
Temp=String_Replace(Temp,"((''|rem).*)","''(.*)(<.+?>)("&KeyWord&ObjectCommand&")+(<.+?>)(.*)",Comment,0) ''注释
MakeLi="<FONT COLOR="&CodeColor&">"&RepVbCrlf(Temp)&"</FONT>"
End Function
Public Function RepVbCrlf(fString)
RepVbCrlf = Replace(fString, CHR(10), "<BR> ")
End Function
Public Function HTMLEncode(fString)
If IsNull(fString) Or fString="" Then
HTMLEncode=""
Exit Function
End If
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
''fString = Replace(fString, CHR(32), " ")
''fString = Replace(fString, CHR(9), " ")
''fString = Replace(fString, CHR(34), """)
''fString = Replace(fString, CHR(39), "''")
''fString = Replace(fString, CHR(13), "")
''fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
''fString = Replace(fString, CHR(10), "<BR> ")
HTMLEncode = fString
End Function
End Class
例子
star=timer()
Set TT = New Wyd_AspCodeHighLight
If Request("xx")<>"" Then
TT.VBCode=Request("xx")
Response.write TT.MakeLi()
REsponse.write "<br>"&FormatNumber(timer()-star,2)*1000
Else
%>
<FORM METHOD=POST action="Index2.asp">
<TEXTAREA NAME="xx" ROWS="30" COLS="80">Class Lih
Private RegEx
Public Keyword,ObjectCommand,Strings,VBCode
Public KeyWordColor,ObjectCommandColor,StringsColor,Comment
Private Sub Class_Initialize()
Set RegEx = New RegExp
KeyWordColor="#0000FF"
ObjectCommandColor="#FF0000"
StringsColor="#FF00FF"
内容版权声明:除非注明,否则皆为本站原创文章。