Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > asp标签引擎 :tagEngine.Class.Asp
【标  题】:asp标签引擎 :tagEngine.Class.Asp
【关键字】:asp,tagEngine.Class.Asp
【来  源】:http://blog.csdn.net/xilo/archive/2006/12/02/1426724.aspx

asp标签引擎 :tagEngine.Class.Asp

Your Ad Here

标签引擎,只是按设定的规则提取标签,没有解析标签功能.....
最大作用:灵活,可以自己定义标签规则,然后就可以定义自己的标签库.....
已经用在一个项目上了,不过是PHP版的....
具体应用以后有时间在写.......

asp,php,asp.net讨论群:3920122

<%
'******************************
'类名:tagEngine
'名称:标签引擎
'日期:2006-11-29
'作者:西楼冷月
'网址:www.xilou.net | www.chinaCMS.org
'描述:只有提取标签功能,没有解析标签功能
'版权:转载请注名出处,作者
'******************************
'最后修改:2006-12-1
'修改次数:2
'修改说明:修改正则,使匹配更精确
'目前版本:v1.1.2
'******************************
Class tagEngine

Private regEx'正则对象

'定义标签规则
Private tagbegin
Private tagend
Private blockbegin_begin
Private blockbegin_end
Private blockend_begin
Private blockend_end
'//初始化
Private Sub Class_Initialize()
    '初始化标签规则
     tagbegin="{"
     tagend="}"
     blockbegin_begin="<Block:"
     blockbegin_end  =">"
     blockend_begin  ="</Block:"
     blockend_end    =">"
     '初始化正则对象
     Set regEx=new RegExp
     regEx.IgnoreCase=True'不区分大小写
     regEx.Global=True'全局匹配
End Sub
Private Sub Class_Terminate()
    '释放对象
     If IsObject(regEx) Then Set regEx=Nothing
End Sub

'方法:resetPattern()
'参数:
'返回:无返回值
'作用:重设标签规则
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)
'参数:temp,要匹配的内容;blockname,区块标志名称
'返回:返回集合对象(Matches)
'作用:获取块标签集合
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)
'参数:temp,要匹配的内容;attributename,属性名称;attributevalue,属性值
'返回:返回集合对象(Matches)
'作用:根据块标签里的某个属性的值取得符合的块集合
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)
'参数:temp,要匹配的内容;attributename,属性名称
'返回:返回集合对象(Matches)
'作用:获取块标签内的属性值
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)
'参数:temp,要匹配的内容;attributename,属性名称;attributevalue,属性值
'返回:返回替换后的字符串
'作用:替换简单标签
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)
'参数:temp,要匹配的内容
'返回:返回清除后的字符串
'作用:清除所有块标签
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)
'参数:temp,要匹配的内容
'返回:返回清除后的字符串
'作用:清除所有的单标签
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)
'参数:errdes,错误描述
'返回:无
'作用:显示错误
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

'******************标准功能结束****************
'以下是自定义扩展功能

'方法:EXT_getSimpleBlocks(temp,blockname)
'参数:temp,要匹配的内容;blockname,区块标志名称
'返回:返回集合对象(Matches)
'作用:获取简单块标签集合
'例子:<Block:new id="" loop=""/>
Public Function EXT_getSimpleBlocks(temp,blockname)
    Dim pattern
    Dim blockbegin,blockend
    '重新定义标签规则
    blockbegin="<Block:"
    blockend  ="/>"
    pattern=blockbegin&"[ ]*"&blockname&"\b[\w\W]*?"&blockend
    regEx.pattern=pattern
    Set EXT_getSimpleBlocks=regEx.Execute(temp)
End Function
End Class
%>

 
prototype开发笔记:【上一篇】
发布自制的asp.net2.0弹出式下拉日历控件:【下一篇】
【相关文章】
  • 使用 ASP.NET AJAX 开发 AJAX-Enabled 网络应用 (一)
  • ASP.NET编程中的十个小技巧
  • ASP.NET Web服务如何工作?
  • Asp.NET 生成静态页
  • 扩展 ASP.NET 2.0 资源提供程序模型
  • ASP.NET配置问题集
  • ASP.NET 2.0中直接将Access数据库导入到Excel文件中
  • 今天你写控件了吗?----ASP.net控件开发系列
  • 使用Asp.net Ajax beta2.0及Anthem.net分别结合js实现仿MSN弹出信息提示窗的示例!(已更新修正源码)
  • 本周ASP.NET英文技术文章推荐[11/26 - 12/02]
  • 【随机文章】
  • 吹牛不上税:龙芯3号处理器将达64核
  • 收集整理了一套JavaScript(Not JScript)手册,分享给大家
  • Photoshop路径终极教程
  • asp.net StreamReader 创建文件
  • A Walk on JSR220
  • Apache+php+tomcat+mysql整合手册
  • 简单的JSP+tomcat+mysql设置(windows下)
  • 将图片储存在MySQL数据库里
  • 在window2k&XP下屏蔽Ctrl+Alt+del
  • Window 服务全攻略大全
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.