欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

VBS教程:對(duì)象-Matches 集合

 更新時(shí)間:2006年11月16日 00:00:00   作者:  

Matches 集合

正則表達(dá)式 Match 對(duì)象的集合。

說(shuō)明

Matches 集合中包含若干獨(dú)立的 Match 對(duì)象,只能使用 RegExp 對(duì)象的 Execute 方法來(lái)創(chuàng)建之。與獨(dú)立的 Match 對(duì)象屬性相同,Matches `集合的一個(gè)屬性是只讀的。

在執(zhí)行正則表達(dá)式時(shí),可能產(chǎn)生零個(gè)或多個(gè) Match 對(duì)象。每個(gè) Match 對(duì)象都提供了與正則表達(dá)式匹配的字符串的訪問(wèn)入口、字符串的長(zhǎng)度,以及標(biāo)識(shí)匹配位置的索引。

下面的代碼將說(shuō)明如何使用正則表達(dá)式查找獲得 Matches 集合,以及如何循環(huán)遍歷集合:

Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches      ' 創(chuàng)建變量。  Set regEx = New RegExp         ' 創(chuàng)建正則表達(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      ' 循環(huán)遍歷Matches集合。    RetStr = RetStr & "Match found at position "    RetStr = RetStr & Match.FirstIndex & ". Match Value is '"    RetStr = RetStr & Match.Value & "'." & vbCRLF  Next  RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))

相關(guān)文章

最新評(píng)論