Regex 如何在没有查找支持的情况下查找单词的特定实例

Regex 如何在没有查找支持的情况下查找单词的特定实例,regex,vba,vbscript,Regex,Vba,Vbscript,我需要在这个7-Zip输出中找到3个属性的值,“Path=”、“Size=”和“Modified=”。我正在使用VBScript.RegExp,因此不支持(正向)查找。我正在努力处理'Path='一个,因为它在那里有两次,我需要第二个实例(10个破折号之后的那个) ^((?使用非捕获组设置左侧上下文,并使用捕获组获取所需结果: (?:-{10}\r?\nPath = |^Size = |^Modified = )(.*) ^--------- non-capturing group ------

我需要在这个7-Zip输出中找到3个属性的值,“Path=”、“Size=”和“Modified=”。我正在使用VBScript.RegExp,因此不支持(正向)查找。我正在努力处理'Path='一个,因为它在那里有两次,我需要第二个实例(10个破折号之后的那个)


^((?使用非捕获组设置左侧上下文,并使用捕获组获取所需结果:

(?:-{10}\r?\nPath = |^Size = |^Modified = )(.*)
^--------- non-capturing group -----------^
                                           ^--^ - capturing group

VBA演示:

Dim re, testString, colMatch, objMatch
Set re = New RegExp
With re
  .Pattern = "(?:-{10}\r?\nPath = |^Size = |^Modified = )(.*)"
  .Global = True
  .Multiline = True
  .IgnoreCase = True
End With
testString = "----------" & vbCrLf & "Path = some/path/here"

Set colMatch = re.Execute(testString)
For Each objMatch In colMatch
  Debug.Print objMatch.SubMatches(0)  ' <- The first submatch is your value
Next
Dim re、testString、colMatch、objMatch
Set re=New RegExp
带re
.Pattern=“(?:-{10}\r?\n路径=| ^Size=| ^Modified=)(.*
.Global=True
.Multiline=True
.IgnoreCase=True
以
testString=“--------------”&vbCrLf&“Path=some/Path/here”
Set colMatch=re.Execute(testString)
对于colMatch中的每个objMatch

Debug.Print objMatch.SubMatches(0)”它在用“.Pattern=”(?:-{10}\r?\nPath=^Size=^Modified=)(.*”`替换其他2^后起作用,@Eddict您没有显示任何输入字符串,也没有显示代码。因此,您有多行文本,添加
.multiline=True
@Eddict它默认在那里:)