", CHR(10)) HTMLDecode = StrEnd IfEnd Function'去掉html标签,去掉换行Function NoHtml(strText) Dim regEx Set regEx = New RegExp regEx.Global = True regEx.IgnoreCase = True regEx.Pattern = "\n" strText = regEx.Replace(strText,"") regEx.Pattern = "\r" strText = regEx.Replace(strText,"") regEx.Pattern = "(.*?)<\/scrīpt>" strText = regEx.Replace(strText,"") regEx.Pattern = "<(.+?)>" strText = regEx.Replace(strText,"")NoHtml = strTextEnd Function function strcurrency(str)str=mid(cstr(formatcurrency(str,2)),2) strcurrency=str end function
asp过滤所有html代码,可以用正则表达式写函数来完成。代码如下:<%
'说明:自定义正则替换函数,直接引用RemoveHTML这个函数就可以
Function RemoveHTML(strHTML)
Dim objRegExp,Match,Matches,k
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
Set Matches = objRegExp.Execute(strHTML)
strHTML = objRegExp.Replace(strHTML,"")
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
'使用示例:
a="<div></p><p>文字内容</p><p></div>"
a=RemoveHTML(a)
response.write a'执行完后,会过滤掉所有html代码,只保留文字
%>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)