让操作更便捷:ASPTable类
发布时间:2016-10-08 21:15:18 所属栏目:Asp教程 来源:网络整理
导读:经常写代码,对于无聊的table、tr、td真是深恶痛绝,一遍又一遍编写着重复无聊的代码,昨天看《 ASP3.0高级编程》时,看到作者的一个ASP Table组件,感觉实在很
|
'分析格式字符串,替换标签
Private Function ExpandString(sourceString)
If sourceString="" Then Exit Function
Dim tokens,newText,cnt
newText=sourceString
tokens=GetTokens(sourceString)
'Join(tokens,"")==""用于判断数组是否为空
If Join(tokens,"")<>"" Then
cnt=1
do while cnt<UBound(tokens)+1
newText=replace(newText,"{$" & tokens(cnt) & "$}",m_RS(tokens(cnt)))
cnt=cnt+1
Loop
End if
ExpandString=newText
End Function
'获取字符串中的所有标签,以数组返回
Private Function GetTokens(tokenString)
Dim regEx, Match, Matches,curIndex
Dim arrTokens()
curIndex=0
Set regEx = New RegExp
regEx.Pattern = "{$w+($}){1}"
regEx.IgnoreCase = True
regEx.Global = True
Set Matches = regEx.Execute(tokenString)
For Each Match in Matches
curIndex=curIndex+1
Redim Preserve arrTokens(curIndex)
arrTokens(curIndex) = Mid(Match.Value,3,len(Match.Value)-4)
Next
GetTokens = arrTokens
End Function
End Class
%>
(编辑:佛山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

