对以下电子邮件正文应用以下正则表达式:
(pls[a-zA-Z0-9 .*-]*) \(([A-Z 0-9]*)\)电子邮件正文:
pls18244a.lam64*fra-pth (PI000581)
pls18856a.10ge*fra-pth (PI0005AW)
pls25040a.10ge*fra-pth (IIE0004WK)
pls27477a.10ge*fra-pth (WL050814)
pls22099a.stm4*par-pth (PI0005TE)返回5个匹配,包含两个组。使用增量变量复制excel行中的每个匹配组的VBA脚本是什么?
发布于 2017-06-07 13:05:57
不对您的正则表达式模式进行任何更改。使用以下方法,您可以遍历每个匹配的组:
str="pls18244a.lam64*fra-pth (PI000581)pls18856a.10ge*fra-pth (PI0005AW)pls25040a.10ge*fra-pth (IIE0004WK)pls27477a.10ge*fra-pth (WL050814)pls22099a.stm4*par-pth (PI0005TE)"
Set objReg = New RegExp
objReg.IgnoreCase=False
objReg.Global=True
objReg.Pattern = "(pls[a-zA-Z0-9 .*-]*) \(([A-Z 0-9]*)\)"
Set objMatches = objReg.Execute(str)
For Each match In objMatches 'The variable match will contain the full match
a= match.Submatches.Count 'total number of groups in the full match
For i=0 To a-1
MsgBox match.Submatches.Item(i) 'display each group
Next
Next
Set objReg = Nothinghttps://stackoverflow.com/questions/44401036
复制相似问题