LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

常用的ASP正则过滤函数 可过滤html js style div font

admin
2010年7月22日 21:52 本文热度 4010
开发程序,经常要用到正则表达式进行过滤一些不需要的东西,比如html js style div font,有时候需要过滤极个别的,有时候需要过滤好几种,不管怎么过滤,万变不离其宗。[br][br] 这是我收藏的一些过滤函数,可以用来过滤您不需要的代码。如果需要过滤多种,可以嵌套使用,也可以自己整合代码。不过不建议嵌套使用,因为那样效率太低。[br][br][br]asp 正则表达式 过滤 所有 html 标记 :[br][br] [img]images/code.gif[/img] 程序代码 function losehtml(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "<\/*[^<>]*>"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losehtml = clstemplosestr[br]end function[br][br]asp 正则表达式 过滤 style 标记 :[br][br] [img]images/code.gif[/img] 程序代码 function losestyletag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "(]*>[^\0]*(<\/style>)+"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losestyletag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 层 div 标记 :[br][br] [img]images/code.gif[/img] 程序代码 function losedivtag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "<(\/){0,1}div[^<>]*>"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losedivtag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 链接 a 标记 :[br][br] [img]images/code.gif[/img] 程序代码 function loseatag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "<(\/){0,1}a[^<>]*>"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]loseatag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 字体 font 标记 :[br][br][br] [img]images/code.gif[/img] 程序代码 function losefonttag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "<(\/){0,1}font[^<>]*>"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losefonttag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br][br]asp 正则表达式 过滤 span 标记 :[br][br]程序代码[br]function losespantag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "<(\/){0,1}span[^<>]*>"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losespantag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br][br]asp 正则表达式 过滤 object 标记 :[br][br][br] [img]images/code.gif[/img] 程序代码 function loseobjecttag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = ""[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]loseobjecttag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 iframe 标记:[br][br] [img]images/code.gif[/img] 程序代码 function loseiframetag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "(]*>[^\0]*(<\/iframe>){1,}"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]loseiframetag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 script :[br][br] [img]images/code.gif[/img] 程序代码 function losescripttag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "(]*>[^\0]*(<\/script>){1,}"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]losescripttag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br]asp 正则表达式 过滤 class 标记 :[br][br] [img]images/code.gif[/img] 程序代码 function loseclasstag(contentstr)[br]dim clstemplosestr,regex[br]clstemplosestr = cstr(contentstr)[br]set regex = new regexp[br]regex.pattern = "(class=){1,}(""|\'){0,1}\s+(""|\'|>|\s){0,1}"[br]regex.ignorecase = true[br]regex.global = true[br]clstemplosestr = regex.replace(clstemplosestr,"")[br]loseclasstag = clstemplosestr[br]set regex = nothing[br]end function[br][br][br][br]字符串替换 replace 的正则表达式 :[br][br][br] [img]images/code.gif[/img] 程序代码 <%function replacereg(str,patrn,replstr,ignor)[br]'=========================================[br]'参数解释:[br]'str 原来的字符串[br]'patrn 要替换的字符串(正则表达式)[br]'replstr 要替换成的字符串[br]'ignor 是否区分大小写(1不区分,0区分)[br]'=========================================[br]dim regex ' 建立变量。[br]if ingor=1 then ingor=true else ingor=false[br]set regex = new regexp ' 建立正则表达式。[br]regex.pattern = patrn ' 设置模式。[br]regex.ignorecase = ignor ' 设置是否区分大小写。[br]regex.global=true[br]replacereg = regex.replace(str,replstr) ' 作替换。[br]end function[br][br]'例如 将 weblank.com 替换成 weblank.com[br]response.write(replacereg("weblank.com","www\.weblank\.com","weblank.com",1))[br][br]%>

该文章在 2010/7/22 21:52:07 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved