佳木斯湛栽影视文化发展公司

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

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

熱門標簽:Linux服務(wù)器 銀行業(yè)務(wù) Mysql連接數(shù)設(shè)置 阿里云 服務(wù)器配置 電子圍欄 團購網(wǎng)站 科大訊飛語音識別系統(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不帶引號的圖片地址加上引號
    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ù)目的某子字符串 全部 被替換為另一個子字符串。
'來源: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ù)字
'來源: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
%>

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

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

    • 400-1100-266
    弥勒县| 军事| 霍山县| 巫山县| 江源县| 沽源县| 隆德县| 永胜县| 从化市| 四会市| 无棣县| 贡嘎县| 万年县| 新巴尔虎左旗| 资溪县| 眉山市| 积石山| 利辛县| 蚌埠市| 长顺县| 韶山市| 湖南省| 鹤庆县| 子长县| 高清| 峨边| 大厂| 白水县| 连城县| 南投市| 芒康县| 繁昌县| 准格尔旗| 澄城县| 大竹县| 安徽省| 玉龙| 孟村| 黄龙县| 清苑县| 洪洞县|