如何将caputure匹配string的一部分? 非捕获组

下面我有一个示例testing用例,如果单词Blah出现在它之前,我想只抓取星期六的值。 下面是我得到的,但由于某种原因,我最终得到“布拉”包括在内。 任何帮助将是伟大的。 谢谢!

Sub regex_practice() Dim pstring As String pstring = "foo" & vbCrLf & "Blah" & vbCrLf & vbCrLf & "Saturday" 'MsgBox pstring Dim regex As Object Set regex = CreateObject("VBScript.RegExp") With regex .Pattern = "(?:Blah)((.|\n)*)Saturday" .Global = True 'If False, would replace only first End With Set matches = regex.Execute(pstring) 

当然。 整个比赛中包含一个非捕捉组。 你可能要找的是在这里抓住合适的捕捉组。
更改

 With regex .Pattern = "(?:Blah)((.|\n)*)Saturday" .Global = True 'If False, would replace only first End With 

 With regex .Pattern = "Blah[\s\S]*?(Saturday)" .Global = True 'If False, would replace only first End With 

然后使用.SubMatches

 If regex.test(pstring) Then Set matches = regEx.Execute(pstring) GetSaturday = matches(0).SubMatches(0) End If 

另外((.|\n)*)是相当糟糕的,而不是使用[\s\S]*?