ASP过滤函数?
发布网友
发布时间:2022-11-23 12:22
我来回答
共2个回答
热心网友
时间:2024-12-03 13:58
正则可以帮你解决
给你一个过滤HTML函数
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"
Set Matches = objRegExp.Execute(strHTML)
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
End Function
热心网友
时间:2024-12-03 13:58
正则表达式
function clearString(str)
dim re,str1,str2,i
set re = new regexp
re.Pattern = "^[ ,。、!?:“”〔〕——()…\u4e00-\u9fa5\s\n\r\t]+$"
for i=1 to len(str)
str1 = mid(str,i,1)
clearString = re.Test(str1)
if clearString=true then
str2 = str2&str1
end if
next
str=str2
clearString = str
end function
function getfile(filename)
dim fso,f,ForReading,text
ForReading = 1
if filename = "" then
getfile = ""
exit function
end if
set fso = Server.CreateObject("Scripting.FileSystemObject")
set f = fso.opentextfile(Server.MapPath(filename),ForReading,true)
text = f.readAll
f.close
set f = nothing
set fso = nothing
getfile = text
end function