<%
str="<dav>sss</dav><br><dav dsfsd></dav><dav ssss>sdsdsdsdsdsdsds</dav><dav>4444</dav><dav ssss>sdsdsdsdsdsdsds</dav>"
Set re = New RegExp
re.Pattern ="<dav ssss>.*?<\/dav>"
re.IgnoreCase = True
re.Global=True
result = re.Replace(str,"")
response.Write(result)
response.write"<br>"
response.Write(server.HTMLEncode(result))%>
正則替換函數(shù)'
Function ReplaceHTML(srcstr, patrn, replStr)
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
regEx.Execute(srcstr)
ReplaceHTML = regEx.Replace(srcstr, replStr)
Set regEx = Nothing
End Function
'說(shuō)明----
'ReplaceHTML(content,"\<.*?\>","")
'替換所有<>之間的內(nèi)容
'ReplaceHTML(content,"\<\!\-{2}開(kāi)始\-{2}\>.*?\<\!\-{2}結(jié)束\-{2}\>","被替換內(nèi)容")
'替換<!--開(kāi)始-->和<!--結(jié)束-->之間的內(nèi)容
<%
'******************************
'函數(shù):RegRemoveHref(HTMLstr)
'參數(shù):HTMLstr,待去除鏈接的字符串
'作者:阿里西西
'日期:2007/7/12
'描述:通過(guò)正則去除字符串中所有的超級(jí)鏈接
'示例:
%>
<%=RegRemoveHref("<a href=/abc/h.html>測(cè)試</a><a href=/abc/h.html>測(cè)試</a><a href=/abc/h.html>測(cè)試</a>")%>
<%'******************************
Function RegRemoveHref(HTMLstr)
Set ra = New RegExp
ra.IgnoreCase = True
ra.Global = True
ra.Pattern = "<a[^>]+>(.+?)<\/a>"
RegRemoveHref = ra.replace(HTMLstr,"$1")
END Function
%>