当然这应该属于正常过滤手法,而还有一种过滤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
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
第二种:
复制代码代码如下:
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
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
简单的应用:
<scriptlanguage="vbs">
Functionnohtml(str)
dimre
Setre=newRegExp
re.IgnoreCase=true
re.Global=True
re.Pattern="<(.[^>]*)>"
str=re.replace(str,"")
nohtml=str
setre=nothing
EndFunction
alert(nohtml("<b>www.zzvips.com</b><ahref='//www.zzvips.com'>快网idc</a>"))
</script>
相关文章
猜你喜欢
- 64M VPS建站:是否适合初学者操作和管理? 2025-06-10
- ASP.NET自助建站系统中的用户注册和登录功能定制方法 2025-06-10
- ASP.NET自助建站系统的域名绑定与解析教程 2025-06-10
- 个人服务器网站搭建:如何选择合适的服务器提供商? 2025-06-10
- ASP.NET自助建站系统中如何实现多语言支持? 2025-06-10

