主頁(yè) > 知識(shí)庫(kù) > 一個(gè)asp替換函數(shù)img里面多余的代碼

一個(gè)asp替換函數(shù)img里面多余的代碼

熱門標(biāo)簽:Linux服務(wù)器 銀行業(yè)務(wù) Mysql連接數(shù)設(shè)置 阿里云 服務(wù)器配置 電子圍欄 團(tuán)購(gòu)網(wǎng)站 科大訊飛語(yǔ)音識(shí)別系統(tǒng)
%
Response.Write(Server.HTMLEncode(FixImg("img onclick=""if(this.widthgt;screen.width-461) window.open('qq/20082181405371.jpg');"" alt="""" border=""0"" src=""qq/20082181405371.jpg"" />")))
%>
%
'功能:將IMG代碼格式化為img src="XXX" />格式.
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不帶引號(hào)的圖片地址加上引號(hào)
    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
%>
%
'功能:返回字符串,其中指定數(shù)目的某子字符串 全部 被替換為另一個(gè)子字符串。
'來(lái)源:http://jorkin.reallydo.com/article.asp?id=406
'需要Bint函數(shù):http://jorkin.reallydo.com/article.asp?id=395

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 InStr( 1, sExpression, sFind, 1) > 0
            sExpression = Replace(sExpression, sFind, sReplaceWith, 1, -1, 1)
            If InStr( 1, sReplaceWith , sFind , 1) >0 Then Exit Do
        Loop
    Else
        Do While InStr(sExpression, sFind) > 0
            sExpression = Replace(sExpression, sFind, sReplaceWith)
            If InStr(sReplaceWith, sFind ) > 0 Then Exit Do
        Loop
    End If
    ReplaceAll = sExpression
End Function
%>
%
'功能:只取數(shù)字
'來(lái)源:http://jorkin.reallydo.com/article.asp?id=395

Function Bint(Str)
    Str = Trim(Str)
    If Str = "" Or IsNull(Str) Or Not IsNumeric(Str) Then Str = "0"
    Bint = Round(Str, 0)
End Function
%>

標(biāo)簽:蚌埠 萍鄉(xiāng) 廣元 江蘇 大理 衢州 衡水 棗莊

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《一個(gè)asp替換函數(shù)img里面多余的代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266