加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

使用ASP编写的语法高亮类显示代码

发布时间:2023-09-19 09:55:48 所属栏目:Asp教程 来源:
导读:此类高亮根据Editplus高亮来做的

复制代码 代码如下:

Class Wyd_AspCodeHighLight
Private RegEx
Public Keyword,ObjectCommand,Strings,VBCode
Public KeyWordColor,ObjectCommandColor,StringsColor,
此类高亮根据Editplus高亮来做的 

复制代码 代码如下:

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   ' 设置是否区分字母的大小写 True 不区分。 
    RegEx.Global = True   ' 设置全程性质。 
    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" '关建字 请自己添加 
ObjectCommand="Left|Mid|Right|Int|Cint|Clng|String|Join|Array" '函数 请自己添加 
VBCode="" 
  End Sub 
  Private Sub Class_Terminate() 
    Set RegEx = Nothing 
  End Sub 
  Private Function M_Replace(Str,Pattern,Color) 
    RegEx.Pattern = Pattern  ' 设置模式。 
    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 Each Match In Matches   ' 遍历 Matches 集合 
       Temp=Re(Match.value) 
       Str = Replace(Str,Match.value,Temp) 
    Next 
RegEx.Pattern = Pattern  ' 设置模式。 
If IsString=1 Then 
       String_Replace=RegEx.Replace(Str,"<font color="&Color&">"$1"</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  ' 设置是否区分字母的大小写。 
   TRegEx.Global = True   ' 设置全程性质。 
   TRegEx.Pattern="<.*?>" 
   Temp=TRegEx.Replace(Str,"") 
   Temp=Replace(Temp,"<","") 
   Temp=Replace(Temp,">","") 
   Re=Temp 
   Set TRegEx=Nothing 
  End Function 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章