'/********************************
'店铺用来包含的文件
'/*******************************
Function include(filename)'filename代表的是文件名
Dim re,content,fso,f,aspStart,aspEnd
set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing
set re=new RegExp
re.pattern="^/s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
'asp=inStr(aspStart,content,"%/>")+2
'response.Write(aspEnd&"|"&aspStart&"<br>"&asp)
do while aspStart>aspEnd+1
'输出% >与<%之中的字符串,如表格等..
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%/>")+2'%/>是转换符
'相当于去掉=号前面包括空格、制表符、换页符前面的的字符串用Response.Write来代替,如:<%=SYS_WEBNAME % >
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
content=""
set re=nothing
End Function
有用的二个函数
'/**************************************
'/移除HTML标签
'/**************************************
Function RemoveHTML(strText)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "<[^>]*>"
RegEx.Global = True
RemoveHTML = RegEx.Replace(strText, "")
End Function
'/*****************************
'/移除链接的代码<a *****></a>
'/*****************************
function removeUrl(strContent)
dim a,b,c,d,e,f
do while instr(strContent,"<a")>0
a=instr(strContent,"<a")
b=instr(strContent,"</a>")
c=b+4-a
d=mid(strContent,a,c)'有链接的字符
e=instr(d,">")
f=left(right(d,len(d)-e),len(right(d,len(d)-e))-4)'无链接的字符
strContent=replace(strContent,d,f)
loop
removeUrl=strContent
end function
本文介绍了一个用于处理ASP脚本的功能,该功能可以读取指定文件并解析其中的ASP代码,同时还提供去除HTML标签和链接的方法。

被折叠的 条评论
为什么被折叠?



