上联网络有多年网站建设经验,下是asp生成静态页方法和函数,通过个函数可以方便的在ASP文件生成静态文件实现网站静态化’【功能】自定义模板标签
Function ProcessCustomTags(ByVal sContent)
Dim objRegEx, Match, Matches
’建立正则表达式
Set objRegEx = New RegExp
’查找内容
objRegEx.Pattern = "<tag:.*/>"
’忽略大小写
objRegEx.IgnoreCase = True
’全局查找
objRegEx.Global = True
’Run the search against the content string we’ve been passed
Set Matches = objRegEx.Execute(sContent)
’循环已发现的匹配
For Each Match in Matches
’Replace each match with the appropriate HTML from our ParseTag function
sContent = Replace(sContent, Match.Value, ParseTag(Match.Value))
Next
’消毁对象
set Matches = nothing
set objRegEx = thing
’返回值
ProcessCustomTags = sContent
End Function
’【功能】取得模板标签的参数名
’如:<tag:loop channelid="1" pagesize="10" title="20" type="NEW" column="1">
function GetAttribute(ByVal strAttribute, ByVal strTag)
Dim objRegEx, Matches
’建立正则表达式
Set objRegEx = New RegExp
’查找内容 (the attribute name followed by double quotes etc)
objRegEx.Pattern = lCase(strAttribute) & "=""[0-9a-zA-Z]*"""
’忽略大小写
objRegEx.IgnoreCase = True
’全局查找
objRegEx.Global = True
’执行搜索
Set Matches = objRegEx.Execute(strTag)
’如有匹配的则返回值, 不然返回空值
if Matches.Count > 0 then
GetAttribute = Split(Matches(0).Value,"""")(1)
else
&nbs