您的位置:首页 > 其它

一个转换输出函数.可以用于模板转换

2006-10-20 15:11 267 查看
'/********************************
'店铺用来包含的文件
'/*******************************
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐