Class wyd_aspcodehighlight
Private RegEx
Public keyword,objectcommand,strings,vbcode
Public Keywordcolor,objectcommandcolor,stringscolor,comment,codecolor
Private Sub class_initialize ()
Set RegEx = New REGEXP
Regex.ignorecase = True ' Sets whether the case-sensitive letter is case-insensitive.
Regex.global = True ' Sets the whole property.
keywordcolor= "#0000FF"
objectcommandcolor= "#FF0000"
stringscolor= "#FF00FF"
comment= "#008000"
Codecolor= "#993300"
keyword= "set| private| If| then| sub| end| function| for| Next| do| while| wend| true| false| Nothing| Class "'", please add your own
objectcommand= "left| mid| Right| Int| Cint| Clng| String| join| Array "' function to add your own
vbcode="
End Sub
Private Sub class_terminate ()
Set RegEx = Nothing
End SUB
Private Function M_replace (str,pattern,color)
Regex.pattern = Pattern ' Set mode.
M_replace=regex.replace (Str, "<font color=" &Color& ">$1</font>")
End Function
Private Function string_replace (str,pattern,pattern1,color,isstring)
Dim Temp,retstr
Regex.pattern =PATTERN1
Set matches = Regex.execute (STR)
For all Match in matches ' traversal matches collection
Temp=re (Match.value)
STR = Replace (str,match.value,temp)
Next
Regex.pattern = Pattern ' Set mode '.
If isstring=1 Then
String_replace=regex.replace (Str, "<font color=" &Color& ">" $ "</font>")
Else
String_replace=regex.replace (Str, "<font color=" &Color& ">$1</font>")
End If
End Function
Private Function Re (STR)
Dim tregex,temp
Set Tregex = New RegExp
Tregex.ignorecase = True ' Sets whether the case of letters is case-sensitive.
Tregex.global = True ' Sets the whole property.
Tregex.pattern= "<.*?>"
Temp=tregex.replace (Str, "")
Temp=replace (Temp, "<", "")
Temp=replace (Temp, ">", "")
Re=temp
Set tregex=nothing
End Function
Public Function Makeli ()
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) ' string
Temp=string_replace (Temp, "(|rem)," "(. *) (<.+?>) (" &KeyWord&ObjectCommand& ") + (<.+?) >) (. *) ", comment,0)" notes
makeli= "<font color=" &CodeColor& ">" &repvbcrlf (Temp) & "</FONT>"
End Function
Public Function Repvbcrlf (fstring)
Repvbcrlf = Replace (fstring, CHR (), "<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 (a) & CHR (a), "</P><P>")
' fstring = Replace (fstring, CHR (), "<BR>")
HTMLEncode = fstring
End Function
End Class