2012-09-06 375 views
5

我在VBA(WORD)中的正則表達式匹配只給出一個結果。vba正則表達式只返回第一個匹配

我創造了這個功能

Function RE6(strData As String) As String 

    Dim RE As Object, REMatches As Object 
    Set RE = CreateObject("vbscript.regexp") 
    With RE 
     .MultiLine = False 
     .Global = False 
     .IgnoreCase = True 
     .Pattern = "\[substep [a-zA-Z]\](.*?); {1}" 
    End With 

    Set REMatches = RE.Execute(strData) 

    RE6 = "" 


End Function 

這裏的問題是,它只是給人的第一結果。例如我的字符串:

[step 1] title for substeps; [substep a] step a; [substep b] step b; [substep c] step c; 

我的結果是:

[子步驟一個步驟A;

只有1個匹配,而不是步驟b和c。

回答

相關問題