asp 过滤html标签
function htmlencode(text)
{
return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
}
function htmldecode(text)
{
return text.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
}
'方法二
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</td> </tr> </tbody> </table>
'过滤html标签方 方法三
<table style="background: #fb7" border="0" cellspacing="1" cellpadding="1" width="620" align="center"> <tbody> <tr> <td bgcolor="#ffe7ce" height="27" width="464"> 代码如下</td> <td style="cursor: pointer" bgcolor="#ffe7ce" width="109" align="center" onclick="doCopy('copy7566')">复制代码</td> </tr> <tr> <td style="padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px" id="copy7566" class="copyclass" bgcolor="#ffffff" valign="top" colspan="2">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)
</td> </tr> </tbody> </table>'过滤html标签方法四
<table style="background: #fb7" border="0" cellspacing="1" cellpadding="1" width="620" align="center"> <tbody> <tr> <td bgcolor="#ffe7ce" height="27" width="464"> 代码如下</td> <td style="cursor: pointer" bgcolor="#ffe7ce" width="109" align="center" onclick="doCopy('copy7433')">复制代码</td> </tr> <tr> <td style="padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px" id="copy7433" class="copyclass" bgcolor="#ffffff" valign="top" colspan="2">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
您可能感兴趣的文章:
php正则过滤html特殊字符
php正则过滤html标签、空格、换行符等的代码示例
asp基础语法
php利用正则过滤链接、标签,空格,换行符程序
php删除字符串中html标签的函数
php用strip_tags完整去除所有html标签的实例分享
php删除html标签及字符串中html标签的代码
php正则过滤指定html标签示例
c#正则过滤图片标签 asp.net正则过滤的例子
php 防注入的一段代码(过滤参数)