ASP Highlight Class

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.