asp 过滤函数

来源:百度知道 编辑:UC知道 时间:2024/06/24 09:36:07
<P>一封特殊的来信
<P>      司徒
上面这两行,我要把不是汉字的部分过滤掉,应该怎么写?
谢谢.

你只想过滤掉<p>,那就这样
response.write replace("<P>一封特殊的来信<P> 司徒 ","<p>","")

用正则表达式 ,下面的函数就是将所有HTML代码全部过滤掉,只留下文字

Public Function HtmlStr(str)
Dim re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="<script(.[^>]*)<\/script>"
str=re.Replace(str,"")
re.Pattern="<(.[^>]*)>"
str=re.Replace(str,"")
set re=Nothing
HtmlStr=str
End Function
PP="<P>一封</P>"
AA=HtmlStr(PP)