国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

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

2020-07-27 13:01:38
字體:
供稿:網(wǎng)友
<%
Response.Write(Server.HTMLEncode(FixImg("<img onclick=""if(this.width&gt;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
%>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 成都市| 安国市| 五大连池市| 托克托县| 贺州市| 白河县| 蓬莱市| 蚌埠市| 竹溪县| 苍梧县| 永川市| 宁都县| 岑溪市| 德兴市| 邢台市| 陆河县| 麻江县| 襄樊市| 吉林市| 林芝县| 泸溪县| 和林格尔县| 泰和县| 长治市| 奉化市| 中方县| 新邵县| 临武县| 邵阳县| 永春县| 兖州市| 泰兴市| 南平市| 泽州县| 留坝县| 法库县| 东阿县| 荥阳市| 锡林郭勒盟| 丰城市| 佛冈县|