欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-10-27 15:20:22
复制代码 代码如下:'============================== '格式化html,sdcms加强版 '=========================...
复制代码 代码如下:

'==============================
'格式化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," ","")
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