久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      正則表達(dá)式的使用 ASP

      復(fù)制代碼 代碼如下:
      <%
      ‘ ————————————————————–
      ‘ Match 對象

      ‘ 匹配搜索的結(jié)果是存放在 Match 對象中,提供了對正則表達(dá)式匹配的只讀屬性的訪問。
      ‘ Match 對象只能通過 RegExp 對象的 Execute 方法來創(chuàng)建,該方法實(shí)際上返回了 Match 對象的集合。
      ‘ 所有的 Match 對象屬性都是只讀的。在執(zhí)行正則表達(dá)式時(shí),可能產(chǎn)生零個(gè)或多個(gè) Match 對象。
      ‘ 每個(gè) Match 對象提供了被正則表達(dá)式搜索找到的字符串的訪問、字符串的長度,以及找到匹配的索引位置等。
      ‘ ○    FirstIndex 屬性,返回在搜索字符串中匹配的位置。FirstIndex屬性使用從零起算的偏移量,該偏移量是相對于搜索字符串的起始位置而言的。換言之,字符串中的第一個(gè)字符被標(biāo)識為字符 0
      ‘ ○    Length 屬性,返回在字符串搜索中找到的匹配的長度。
      ‘ ○    Value 屬性,返回在一個(gè)搜索字符串中找到的匹配的值或文本。
      ‘ ————————————————————–
      ‘ Response.Write RegExpExecute(“[ij]s.”, “IS1 Js2 IS3 is4”)
      Function RegExpExecute(patrn, strng)
          Dim regEx, Match, Matches            ‘建立變量。
          SET  regEx = New RegExp                ‘建立正則表達(dá)式。
          regEx.Pattern = patrn                ‘設(shè)置模式。
          regEx.IgnoreCase = True                ‘設(shè)置是否不區(qū)分字符大小寫。
          regEx.Global = True                    ‘設(shè)置全局可用性。
          SET  Matches = regEx.Execute(strng)    ‘執(zhí)行搜索。
          For Each Match in Matches            ‘遍歷匹配集合。
              RetStr = RetStr & “Match found at position ”
              RetStr = RetStr & Match.FirstIndex & “. Match Value is ‘”
              RetStr = RetStr & Match.Value & “‘.” & “<BR>”
          Next
          RegExpExecute = RetStr
      End Function

      ‘ ——————————————————————–
      ‘ Replace 方法
      ‘ 替換在正則表達(dá)式查找中找到的文本。
      ‘ ——————————————————————–
      ‘ Response.Write RegExpReplace(“fox”, “cat”) & “<BR>”        ‘ 將 ‘fox’ 替換為 ‘cat’。
      ‘ Response.Write RegExpReplace(“(S+)(s+)(S+)”, “$3$2$1”)    ‘ 交換詞對.
      Function RegExpReplace(patrn, replStr)
          Dim regEx, str1                    ‘ 建立變量。
          str1 = “The quick brown fox jumped over the lazy dog.”
          SET  regEx = New RegExp            ‘ 建立正則表達(dá)式。
          regEx.Pattern = patrn            ‘ 設(shè)置模式。
          regEx.IgnoreCase = True            ‘ 設(shè)置是否不區(qū)分大小寫。
          RegExpReplace = regEx.Replace(str1, replStr)    ‘ 作替換。
      End Function

      ‘ ——————————————————————–
      ‘ 使用 Test 方法進(jìn)行搜索。
      ‘ 對指定的字符串執(zhí)行一個(gè)正則表達(dá)式搜索,并返回一個(gè) Boolean 值
      ‘ 指示是否找到匹配的模式。正則表達(dá)式搜索的實(shí)際模式是通過 RegExp 對象的 Pattern 屬性來設(shè)置的。
      ‘ RegExp.Global 屬性對 Test 方法沒有影響。
      ‘ 如果找到了匹配的模式,Test 方法返回 True;否則返回 False
      ‘ ——————————————————————–
      ‘ Response.Write RegExpTest(“功能”, “重要功能”)
      Function RegExpTest(patrn, strng)
          Dim regEx, retVal                ‘ 建立變量。
          SET  regEx = New RegExp            ‘ 建立正則表達(dá)式。
          regEx.Pattern = patrn            ‘ 設(shè)置模式。
          regEx.IgnoreCase = False        ‘ 設(shè)置是否不區(qū)分大小寫。
          retVal = regEx.Test(strng)        ‘ 執(zhí)行搜索測試。
          If retVal Then
              RegExpTest = “找到一個(gè)或多個(gè)匹配。”
          Else
              RegExpTest = “未找到匹配。”
          End If
      End Function
      %>

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號