复制代码 代码如下:
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
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)'' 字符串
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"
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 '' 设置是否区分字母的大小写。
RegEx.Global = True '' 设置全程性质。
RegEx.Pattern = Pattern '' 设置模式。</TEXTAREA>
<INPUT TYPE="submit" value=fff>
</FORM>
<%
End If
%>
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
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)'' 字符串
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"
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 '' 设置是否区分字母的大小写。
RegEx.Global = True '' 设置全程性质。
RegEx.Pattern = Pattern '' 设置模式。</TEXTAREA>
<INPUT TYPE="submit" value=fff>
</FORM>
<%
End If
%>
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
暂无评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
2024年11月23日
2024年11月23日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]