Regex Vbs正则表达式如何处理多个匹配

Regex Vbs正则表达式如何处理多个匹配,regex,vbscript,Regex,Vbscript,我找到了一个匹配的模式。如果我有多项选择,我应该如何处理其他匹配 Dim re, targetString, colMatch, objMatch Set re = New regexp With re .pattern = ">([\s,\S]*?)<" .Global = True .IgnoreCase = True .Multiline = True End With targetString = ">test and test< &g

我找到了一个匹配的模式。如果我有多项选择,我应该如何处理其他匹配

    Dim re, targetString, colMatch, objMatch
Set re = New regexp
With re
  .pattern = ">([\s,\S]*?)<" 
  .Global = True
  .IgnoreCase = True
  .Multiline = True
End With
targetString = ">test and test<  >test2 and test2<   >test3 and test3<"
Set colMatch = re.Execute(targetString)
For Each objMatch In colMatch
result = objMatch.SubMatches.Item(0)
Next
Dim re,targetString,colMatch,objMatch
Set re=New regexp
带re

.pattern=“>([\s\s]*?)测试和测试<>test2和test2<>test3和test3在使用
next
结束循环之前,您需要处理
结果


当前,您将每个结果分配给
result
,但随后立即结束循环并转到下一个结果。

考虑下面的示例。它显示了如何将所有子匹配放入数组中

Dim strSourceString, objMatch, arrResults
strSourceString = ">test and test<  >test2 and test2<   >test3 and test3<"
Set objList = CreateObject("Scripting.Dictionary")
With New RegExp
    .Pattern = ">([\s,\S]*?)<"
    .Global = True
    .IgnoreCase = True
    .MultiLine = True
    For Each objMatch In .Execute(strSourceString)
        objList(objList.Count) = objMatch.SubMatches.Item(0)
    Next
End With
arrResults = objList.Items
Set objList = Nothing
MsgBox Join(arrResults, "; ") ' array contains submatches
Dim strSourceString、objMatch、arrResults

strSourceString=“>test and test<>test2和test2<>test3和test3([\s\s]*?)可能是Wecouldstealavan,感谢您的评论。你能提供一份工作报告吗example@Alex你能自己试试吗?煎蛋卷,谢谢你的帮助