ASP去除所有html标签
function nohtml(str)
dim re
Set re=new RegExp
re.IgnoreCase =true
re.Global=True
re.Pattern="(<.[^<]*>)"
str=re.replace(str," ")
re.Pattern="(</[^<]*>)"
str=re.replace(str," ")
nohtml=str
set re=nothing
end function
Function delHtml(strHtml) '做了一个函数名叫delhtml
Dim objRegExp, strOutput
Set objRegExp = New Regexp ' 建立正则表达式
objRegExp.IgnoreCase = True ' 设置是否区分大小写
objRegExp.Global = True '是匹配所有字符串还是只是第一个
objRegExp.Pattern = "(<[a-zA-Z].*?>)|(<[/][a-zA-Z].*?>)" ' 设置模式引号中的是正则表达式,用来找出html标签
strOutput = objRegExp.Replace(strHtml, "") '将html标签去掉
strOutput = Replace(strOutput, "<", "<") '防止非html标签不显示
strOutput = Replace(strOutput, ">", ">")
delHtml = strOutput
Set objRegExp = Nothing
End Function
Function RemoveHtml(byval strContent)
Dim objReg ,strTmp
If strContent="" OR ISNull(strContent) Then Exit Function
Set objReg=new RegExp
objReg.IgnoreCase =True
objReg.Global=True
objReg.Pattern="<(.[^>]*)>"
strTmp=objReg.Replace(strContent, "|")
Set objReg=Nothing
RemoveHtml=strTmp
strTmp=""
End Function
str="你好fsdgoijut%%$015$%%fefw%#$fw"
chkstartstr = "%%$" '前边的标示字符串
chkendstr = "$%%" '后边的标示字符串
startstr = InStr(str,chkstartstr) + len(chkstartstr) '找到开始位置
endstr = InStr(str,chkendstr) '找到结束位置
censtr = Mid(str,startstr,endstr - startstr) '截取字符串