国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

Asp class一個(gè)標(biāo)簽引擎類tagEngine.Class_ASP教程

2024-05-04 11:04:26
字體:
供稿:網(wǎng)友

推薦:Asp+Ajax實(shí)現(xiàn)無刷新增加好友
由于工作關(guān)系,要做個(gè)人空間,其中有一功能是增加對(duì)方為好友.如圖: 用到的方法是ajax,費(fèi)話少說貼切代碼: a href=javascript:void(0); onClick =add_username('%= rs(username) %');加為好友/a,用到的js驗(yàn)證: script language = JavaScript src=ajax.

一個(gè)用來實(shí)現(xiàn)tag功能的asp類,具體的作用,如果您可以讀懂的話就可以明白了了。

修改記錄:
1,增加擴(kuò)展函數(shù),2006-12-3

<%
'******************************
'類名:tagEngine
'名稱:標(biāo)簽引擎
'日期:2006-11-29
'作者:西樓冷月
'網(wǎng)址:www.xilou.net | www.chinaCMS.org
'描述:只有提取標(biāo)簽功能,沒有解析標(biāo)簽功能
'版權(quán):轉(zhuǎn)載請(qǐng)注名出處,作者
'******************************
'最后修改:2006-12-3
'修改次數(shù):3
'修改說明:修改正則,使匹配更精確
'目前版本:v1.1.3
'******************************
Class tagEngine

Private regEx'正則對(duì)象

'定義標(biāo)簽規(guī)則
Private tagbegin
Private tagend
Private blockbegin_begin
Private blockbegin_end
Private blockend_begin
Private blockend_end
'//初始化
Private Sub Class_Initialize()
'初始化標(biāo)簽規(guī)則
tagbegin="{"
tagend="}"
blockbegin_begin="<Block:"
blockbegin_end =">"
blockend_begin ="</Block:"
blockend_end =">"
'初始化正則對(duì)象
Set regEx=new RegExp
regEx.IgnoreCase=True'不區(qū)分大小寫
regEx.Global=True'全局匹配
End Sub
Private Sub Class_Terminate()
'釋放對(duì)象
If IsObject(regEx) Then Set regEx=Nothing
End Sub

'方法:resetPattern()
'參數(shù):
'返回:無返回值
'作用:重設(shè)標(biāo)簽規(guī)則
Public Sub resetPattern(tagbegin,tagend,_
blockbegin_begin,_
blockbegin_end,_
blockend_begin,_
blockend_end _
)
tagbegin=tagbegin
tagend=tagend
blockbegin_begin=blockbegin_begin
blockbegin_end =blockbegin_end
blockend_begin =blockend_begin
blockend_end =blockend_end
End Sub

'方法:getBlocks(temp,blockname)
'參數(shù):temp,要匹配的內(nèi)容;blockname,區(qū)塊標(biāo)志名稱
'返回:返回集合對(duì)象(Matches)
'作用:獲取塊標(biāo)簽集合
Public Function getBlocks(temp,blockname)
Dim pattern
pattern="("&blockbegin_begin&"[ ]*"&blockname&"/b[/w/W]*?"&blockbegin_end
pattern=pattern&")([/w/W]*?)"&blockend_begin&"[ /n/r]*"&blockname&"[ ]*"&blockend_end
'Response.Write pattern
regEx.Pattern=pattern
Set getBlocks=regEx.Execute(temp)'返回匹配集合
End Function

'方法:getBlockByAtt(temp,attributename,attributevalue)
'參數(shù):temp,要匹配的內(nèi)容;attributename,屬性名稱;attributevalue,屬性值
'返回:返回集合對(duì)象(Matches)
'作用:根據(jù)塊標(biāo)簽里的某個(gè)屬性的值取得符合的塊集合
Public Function getBlockByAtt(temp,attributename,attributevalue)
Dim pattern
pattern="("&blockbegin_begin&"[/w/W]*?[ /n/r]+"&attributename
pattern=pattern&"[ ]*=[ ]*/"&Chr(34)&attributevalue&"/"&Chr(34)&"[ /n/r]*[/w/W]*?"
pattern=pattern&blockbegin_end
pattern=pattern&")([/w/W]*?)"&blockend_begin&"[/w/W]*?"&blockend_end
'Response.Write pattern
regEx.Pattern=pattern
Set getBlockByAtt=regEx.Execute(temp)'返回匹配集合
End Function

'方法:getAttValue(temp,attributename)
'參數(shù):temp,要匹配的內(nèi)容;attributename,屬性名稱
'返回:返回集合對(duì)象(Matches)
'作用:獲取塊標(biāo)簽內(nèi)的屬性值
Public Function getAttValue(temp,attributename)
Dim pattern
pattern="[ /n/r]+"&attributename&"[ ]*=[ ]*/"&Chr(34)&"([^/f/n/r/t/v/"&Chr(34)&"]*?)/"&Chr(34)
'Response.Write pattern
regEx.Pattern=pattern
Set getAttValue=regEx.Execute(temp)
End Function

'方法:parseTag(temp,tagname,tagvalue)
'參數(shù):temp,要匹配的內(nèi)容;attributename,屬性名稱;attributevalue,屬性值
'返回:返回替換后的字符串
'作用:替換簡單標(biāo)簽
Public Function parseTag(temp,tagname,tagvalue)
Dim pattern
'pattern=tagbegin&"[ ]*"&tagname&"[ ]*"&tagend
pattern=tagbegin&tagname&tagend
regEx.pattern=pattern
parseTag=regEx.Replace(temp,tagvalue)
End Function

'方法:clearBlocks(temp)
'參數(shù):temp,要匹配的內(nèi)容
'返回:返回清除后的字符串
'作用:清除所有塊標(biāo)簽
Public Function clearBlocks(temp)
Dim pattern
pattern=blockbegin_begin&"[/w/W]*?"&blockbegin_end&"[/w/W]*?"
pattern=pattern&blockend_begin&"[/w/W]*?"&blockend_end
regEx.pattern=pattern
clearBlocks=regEx.Replace(temp,"")
End Function

'方法:clearTags(temp)
'參數(shù):temp,要匹配的內(nèi)容
'返回:返回清除后的字符串
'作用:清除所有的單標(biāo)簽
Public Function clearTags(temp)
Dim pattern
pattern=tagbegin&"[^/f/n/r/t/v]*?"&tagend
regEx.pattern=pattern
clearTags=regEx.Replace(temp,"")
End Function

'方法:showError(errdes)
'參數(shù):errdes,錯(cuò)誤描述
'返回:無
'作用:顯示錯(cuò)誤
Public Sub showError(errdes)
Dim errinfo,cssstyle
cssstyle="style="&Chr(34)
cssstyle=cssstyle&"font:bold 12px 150%,'Arial';border:1px solid #CC3366;"
cssstyle=cssstyle&"width:50%;color:#990066;padding:2px;"&Chr(34)
errinfo=vbcrlf&"<ul "&cssstyle&"><li>"&errdes&"</li></ul>"&vbcrlf
Response.Write errinfo
End Sub

'******************標(biāo)準(zhǔn)功能結(jié)束****************
'以下是自定義擴(kuò)展功能

'方法:EXT_getSimpleBlocks(temp,blockname)
'參數(shù):temp,要匹配的內(nèi)容;blockname,區(qū)塊標(biāo)志名稱
'返回:返回集合對(duì)象(Matches)
'作用:獲取簡單塊標(biāo)簽集合
'例子:<Block:new id="" loop=""/>
Public Function EXT_getSimpleBlocks(temp,blockname)
Dim pattern
Dim blockbegin,blockend
'重新定義標(biāo)簽規(guī)則
blockbegin="<Block:"
blockend ="/>"
pattern=blockbegin&"[ ]*"&blockname&"/b[/w/W]*?"&blockend
regEx.pattern=pattern
Set EXT_getSimpleBlocks=regEx.Execute(temp)
End Function

'******************標(biāo)準(zhǔn)功能結(jié)束****************
'以下是自定義擴(kuò)展功能

'方法:EXT_getSimpleBlocks(temp,blockname)
'參數(shù):temp,要匹配的內(nèi)容;blockname,區(qū)塊標(biāo)志名稱
'返回:返回集合對(duì)象(Matches)
'作用:獲取簡單塊標(biāo)簽集合
'例子:<Block:new id="" loop=""/>
Public Function EXT_getSimpleBlocks(temp,blockname)
Dim pattern
Dim blockbegin,blockend
'重新定義標(biāo)簽規(guī)則
blockbegin="<Block:"
blockend ="/>"
pattern=blockbegin&"[ ]*"&blockname&"/b[/w/W]*?"&blockend
regEx.pattern=pattern
Set EXT_getSimpleBlocks=regEx.Execute(temp)
End Function

'方法:EXT_getTEXT(path)
'參數(shù):path,要讀取的文本相對(duì)或絕對(duì)路徑
'返回:返回文本內(nèi)容
'作用: 讀取文件
'例子:c=EXT_getTEXT("tpl.htm")
Public Function EXT_getTEXT(path)
Dim fso,f,text
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f=Fso.OpenTextFile(path)
text=f.ReadAll
If Err Then
Err.Clear
showError "讀取文件出錯(cuò)..."
If IsObject(fso) Then Set fso=Nothing
Exit Function
End If
If IsObject(fso) Then Set fso=Nothing
EXT_getTEXT=text
End Function

'方法:EXT_getIncludeFile(temp)
'參數(shù):temp,要匹配的內(nèi)容
'返回:返回集合對(duì)象(Matches)
'作用: 解析<!--#include file="tpl.html"-->的區(qū)塊
'例子:EXT_getIncludeFile(temp)(0).SubMatches(0),返回第一個(gè)匹配的文件名
Public Function EXT_getIncludeFile(temp)
Dim pattern
Dim blockbegin,blockend
'重新定義標(biāo)簽規(guī)則
blockbegin="<!--#include"
blockend ="-->"
pattern=blockbegin&"[ ]*file[ ]*=[ ]*/""([/w/W]*?)/""[ ]*"&blockend
regEx.pattern=pattern
Set EXT_getIncludeFile=regEx.Execute(temp)
End Function

End Class
%>

分享:ASP限制ip投票完整實(shí)例代碼
由于工作關(guān)系,要做個(gè)人空間,其中有一功能是對(duì)用戶投票,要求同一IP只能對(duì)同一用戶投票一次,貼Asp代碼: % '作者:無情 出處: db_conn(dbs) Voteusername=trim(request.QueryString(username)) rs_create(select username from [user] where username ='

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 沙雅县| 兰溪市| 阜康市| 布尔津县| 利川市| 县级市| 金乡县| 富顺县| 冀州市| 贵溪市| 岳池县| 庄浪县| 阿荣旗| 鄂伦春自治旗| 谢通门县| 大兴区| 石楼县| 石景山区| 兴海县| 边坝县| 临海市| 门头沟区| 兰考县| 西青区| 西城区| 西华县| 旬邑县| 泸西县| 牙克石市| 商水县| 长乐市| 鄢陵县| 新化县| 土默特左旗| 文安县| 上思县| 共和县| 共和县| 屯门区| 怀来县| 固阳县|