Function strCut(strContent,StartStr,EndStr,CutType)
'strContent 要截取的内容
'StartStr 开始标志字符
'EndStr 结束标志字符
'CutType 截取类型 1--包括开始,结尾标记 2----不包括开始,结尾标记
Dim strHtml,S1,S2
strHtml = strContent
On Error Resume Next
If CutType=2 Then'不包括开始,结尾标记
S1 = InStr(strHtml,StartStr)+Len(StartStr)
S2 = InStr(S1,strHtml,EndStr)
If Err Then
response.write "Unknow Wrong:"&err.description&"---BG:" & S1 & " End:"&S2&"
"
Err.Clear
strCut=""
Exit Function
Else
If S1>Len(StartStr) and S2>0 then
strCut=Mid(strHtml,S1,S2-S1)
Else
strCut=""
End If
End if
' response.Write strCut
' response.End()
Else'包括开始,结尾标记
S1 = InStr(strHtml,StartStr)
S2 = InStr(S1,strHtml,EndStr)+Len(EndStr)
If Err Then
response.write "Unknow Wrong:"&err.description&"---BG:" & S1 & " End:"&S2&"
"
Err.Clear
strCut=""
Exit Function
Else
If S1>0 and S2>Len(EndStr) then
strCut=Mid(strHtml,S1,S2-S1)
Else
strCut=""
End If
End if
End If
End Function
2.html过滤函数,也过滤一些 回车,空格之类的
Function FormatStr(str)
Dim s1,s2
If str<>"" then
str=replace(replace(Trim(str),chr(32)&chr(32),""),chr(9),"")
DO While (instr(str,">")>0 and instr(str,"<")>0)
s1=InStr(str,"<")
s2=Instr(s1,str,">")
If s1>0 and s2>0 then
str=replace(str,mid(str,s1,s2-s1+1),"")
End if
Loop
str=replace(replace(str,"<","<"),">",">")
str=Replace(Replace(Replace(replace(replace(str,chr(13),""),chr(10),""),"""","”"),"'","’")," ","")
FormatStr=str
Else
FormatStr=""
End if
End Function
来源:csdn