展会信息港展会大全

asp 过滤html标签 android软件开发教程
来源:互联网   发布日期:2016-03-01 11:41:05   浏览:1883次  

导读:这是四款asp 过滤html标签函数与方法,这些大全部都是利用正则表达式来过滤以<与>的数据,然后替换里面的东西,这样asp过滤html的函数不成功了。function htmlencode(t...

这是四款asp 过滤html标签函数与方法,这些大全部都是利用正则表达式来过滤以<与>的数据,然后替换里面的东西,这样asp过滤html的函数不成功了。

function htmlencode(text)

{

return text.replace(/&/g, '&amp').replace(/"/g, ' ').replace(/</g, '&lt;').replace(/>/g, '&gt;');

}

function htmldecode(text)

{

return text.replace(/ /g, '&').replace(/ /g, '"').replace(/&lt;/g, '<').replace(/&gt;/g, '>');

}

方法二

function nohtml(str)

dim re

set re=new regexp

re.ignorecase =true

re.global=true

re.pattern="<(.[^>]*)>"

str=re.replace(str,"")

nohtml=str

set re=nothing

end function'过滤html标签方

方法三

function filterhtml(strtofilter)

dim objregexp, match, matches

set objregexp = new regexp

objregexp.ignorecase = true

objregexp.global = true

取闭合的<>

objregexp.pattern = "<.+?>"

进行匹配

set matches = objregexp.execute(strtofilter)

遍历匹配集合,并替换掉匹配的项目

for each match in matches

strtofilter=replace(strtofilter,match.value,"")

next

filterhtml=strtofilter

set objregexp = nothing

end function

调用

str=filterhtml(str)

过滤html标签方法四

function nohtml(str)

dim re

set re=new regexp

re.ignorecase =true

re.global=true

re.pattern="(<.[^<]*>)"

str=re.replace(str,"")

re.pattern="(</[^<]*>)"

str=re.replace(str,"")

nohtml=str

set re=nothing

end function

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港