asp中格式化HTML函数代码 SDCMS加强版

编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
主要用来去除html中的script,iframe等html标记,需要的朋友可以参考下。
代码如下:

'==============================
'格式化HTML,SDCMS加强版
'==============================
Function Nohtml(ByVal t0)
IF Len(t0)=0 Or IsNull(t0) Then
Nohtml=""
Exit Function
End IF
Dim Regs,Matches,Match
Set Regs=New Regexp
Regs.Ignorecase=True
Regs.Global=True
'过滤掉JS,Iframe
Regs.pattern ="<script.+?/script>"
t0=Regs.Replace(t0,"")
Regs.pattern ="<iframe.+?/iframe>"
t0=Regs.Replace(t0,"")
'再过滤其他
Regs.Pattern="<.+?>"
Set Matches=Regs.Execute(t0)
IF Matches.Count>0 Then
For Each Match In Matches
t0=Replace(t0,Match.value,"")
Next
End IF
t0=Replace(t0,"&nbsp;","")
t0=Replace(t0,vbCrLf,"")
t0=Replace(t0," ","")
t0=Replace(t0," ","")
t0=Replace(t0,CHR(9),"")
t0=Replace(t0,CHR(13),"")
t0=Replace(t0,CHR(10),"")
t0=Replace(t0,CHR(22),"")
Set Regs=Nothing
Nohtml=t0
End Function

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板