ASP syntax Highlight class code _asp class

Source: Internet
Author: User
This class is highlighted according to EditPlus highlight

Copy Code code as follows:

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 of the letter is not case-sensitive.
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 words
Objectcommand= "left| mid| Right| Int| Cint| Clng| String| join| Array ' function please add yourself
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 the 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)" Note
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




Example

Copy Code code as follows:

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= "cols=" >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"
Comment= "#008000"
Keyword= "If| end| for| Next| function| then| do| while| wend| Class "
Vbcode= ""
End Sub
Private Sub Class_Terminate ()
Set RegEx = Nothing
End Sub
Private Function m_replace (Str,pattern,color)
Regex.ignorecase = False ' Sets whether the case of letters is case-sensitive.
Regex.global = True ' Sets the whole property.
Regex.pattern = Pattern ' Set mode. </TEXTAREA>
<input type= "Submit" value=fff>
</FORM>
<%end if%>

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.