asp中格式化HTML函数代码 SDCMS加强版
程序员文章站
2022-05-18 11:17:21
复制代码 代码如下:'============================== '格式化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