• <td id="ae6ms"><li id="ae6ms"></li></td>
  • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
  • <table id="ae6ms"></table>
  • <td id="ae6ms"></td>
    <td id="ae6ms"></td>
  • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
  • <td id="ae6ms"></td>
  • <table id="ae6ms"><li id="ae6ms"></li></table>
  • <table id="ae6ms"></table>
    西西軟件園多重安全檢測下載網站、值得信賴的軟件下載站!
    軟件
    軟件
    文章
    搜索

    首頁編程開發ASP → 運用正則表達式在Asp中過濾Html標簽代碼的四種不同方法

    運用正則表達式在Asp中過濾Html標簽代碼的四種不同方法

    相關軟件相關文章發表評論 來源:本站整理時間:2010/6/8 14:57:58字體大?。?em class="fontsize">A-A+

    作者:admin點擊:883次評論:0次標簽: Html

    • 類型:電子資料大?。?i>3.9M語言:中文 評分:10.0
    • 標簽:
    立即下載

    Asp過濾Html代碼方法一

    Function RemoveHTML(strHTML)
    Dim objRegExp, Match, Matches
    Set objRegExp = New Regexp
    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    '取閉合的<>
    objRegExp.Pattern = "<.+?>"
    '進行匹配
    Set Matches = objRegExp.Execute(strHTML)
    ' 遍歷匹配集合,并替換掉匹配的項目
    For Each Match in Matches
    strHtml=Replace(strHTML,Match.Value,"")
    Next
    RemoveHTML=strHTML
    Set objRegExp = Nothing
    End Function

    過濾圖片正則表達式

    <img.+?>

    Asp過濾Html代碼方法二

    Function delHtml(strHtml)

    Dim objRegExp, strOutput
    Set objRegExp = New Regexp ' 建立正則表達式

    objRegExp.IgnoreCase = True ' 設置是否區分大小寫
    objRegExp.Global = True '是匹配所有字符串還是只是第一個
    objRegExp.Pattern = "(<[a-zA-Z].*?>)|(<[\/][a-zA-Z].*?>)" ' 設置模式引號中的是正則表達式,用來找出html標簽

    strOutput = objRegExp.Replace(strHtml, "") '將html標簽去掉
    strOutput = Replace(strOutput, "<", "<") '防止非html標簽不顯示
    strOutput = Replace(strOutput, ">", ">")
    delHtml = strOutput

    Set objRegExp = Nothing
    End Function

    'srt1是你要去除html代碼字符串,可以其它任何地方讀取過來。
    str1 = "<meta http-equiv=""refresh"" content=""0;URL=apple/default.htm""><title>正</3>在轉到 ... ...</title>"
    '應用函數
    Response.Write(delHtml(str1))

    Asp過濾Html代碼方法三

    轉化html標簽為code代碼

    function coder(str)
    dim i
    if isnull(str) then : coder="" : exit function : end if
    for i = 1 to len(str)
    select case mid(str,i,1)
    case "<" : coder = coder &"&lt;"
    case ">" : coder = coder &"&gt;"
    case "&" : coder = coder &"&amp;"
    case chr(9) : coder = coder &"&nbsp; &nbsp; "
    case chr(13) : coder = coder &"<br>"
    case chr(32) : coder = coder &"&nbsp;"
    case chr(34) : coder = coder &"&quot;"
    case chr(39) : coder = coder &"&#39;"
    case else : coder = coder & mid(str,i,1)
    end select
    next
    end function


    過濾javascript字符

    function movejs(str)
    dim objregexp,str1

    set objregexp=new regexp

    objregexp.ignorecase =true

    objregexp.global=true


    objregexp.pattern="\<script.+?\<\/script\>"

    a=objregexp.replace(str,"")

    objregexp.pattern="\<[^\<]+>"

    movejs=objregexp.replace(a,"")
    end function


    過濾html標簽只剩<br>

    function filterhtml(byval fstring)
    if isnull(fstring) or trim(fstring)="" then
    filterhtml=""
    exit function
    end if

    fstring = replace(fstring, "<br />", "[br]")
    fstring = replace(fstring, "<br>", "[br]")

    '過濾html標簽
    dim re
    set re = new regexp
    re.ignorecase=true
    re.global=true
    re.pattern="<(.+?)>"
    fstring = re.replace(fstring, "")
    set re=nothing

    fstring = replace(fstring, "[br]", "<br />")
    filterhtml = fstring
    end function

      相關評論

      閱讀本文后您有什么感想? 已有人給出評價!

      • 8 喜歡喜歡
      • 3 頂
      • 1 難過難過
      • 5 囧
      • 3 圍觀圍觀
      • 2 無聊無聊

      熱門評論

      最新評論

      發表評論 查看所有評論(0)

      昵稱:
      表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
      字數: 0/500 (您的評論需要經過審核才能顯示)
      女人让男人桶30分钟免费视频,女人张开腿让男人桶个爽,一进一出又大又粗爽视频
    • <td id="ae6ms"><li id="ae6ms"></li></td>
    • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
    • <table id="ae6ms"></table>
    • <td id="ae6ms"></td>
      <td id="ae6ms"></td>
    • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
    • <td id="ae6ms"></td>
    • <table id="ae6ms"><li id="ae6ms"></li></table>
    • <table id="ae6ms"></table>