日期:2011-12-25 浏览次数:21041 次
以下是引用片段: <% Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width>screen.width-461) window.open(’qq/20082181405371.jpg’);"" alt="""" border=""0"" src=""qq/20082181405371.jpg"" />"))) %> <% ’功能:将IMG代码格式化为<img src="XXX" />格式. ’参考:http://www.aiyiweb.com Function FixImg(sString) Dim sReallyDo, regEx, iReallyDo Dim oMatches, cMatch Dim tStartTime, tEndTime If IsNull(sString) Then FixImg = "" Exit Function End If sReallyDo = sString On Error Resume Next sReallyDo = Replace(sReallyDo, vbCr, " ") sReallyDo = Replace(sReallyDo, vbLf, " ") sReallyDo = Replace(sReallyDo, vbTab, " ") sReallyDo = Replace(sReallyDo, "<img ", vbCrLf & "<img ", 1, -1, 1) sReallyDo = Replace(sReallyDo, "/>", " />", 1, -1, 1) sReallyDo = ReplaceAll(sReallyDo, "= ", "=", True) sReallyDo = ReplaceAll(sReallyDo, "> ", ">", True) sReallyDo = Replace(sReallyDo, "><", ">" & vbCrLf & "<") sReallyDo = Trim(sReallyDo) On Error GoTo 0 Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True ’//去除onclick,onload等脚本 regEx.Pattern = "\s[on].+?=([\""|\’])(.*?)\1" sReallyDo = regEx.Replace(sReallyDo, "") ’//将SRC不带引号的图片地址加上引号 regEx.Pattern = "<img.*?\ssrc=([^\""\’\s][^\""\’\s>]*).*?>" sReallyDo = regEx.Replace(sReallyDo, "<img src=""$1"" />") ’//正则匹配图片SRC地址 regEx.Pattern = "<img.*?\ssrc=([\""\’])([^\""\’]+?)\1.*?>" sReallyDo = regEx.Replace(sReallyDo, "<img src=""$2"" />") FixImg = sReallyDo End Function %> <% ’功能:返回字符串,其中指定数目的某子字符串 全部 被替换为另一个子字符串。 ’来源:http://www.aiyiweb.com Function ReplaceAll(sExpression, sFind, sReplaceWith, bAll) If IsNull(sExpression) Then ReplaceAll = "" : Exit Function If (StrComp(bAll, "True", 1) = 0) Or (CBool(Bint(bAll)) = True) Then Do While 
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|