当然这应该属于正常过滤手法,而还有一种过滤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,"")
nohtml=str
set re=nothing
end function
简单的应用:
如对本文有疑问,
点击进行留言回复!!
网友评论