我想从文本中提取一些东西,例如在这个文本中:
r_w + [DPTPSRMX] < psrmmn_w und B_zepsrpl
我要提取[]
本例中的内容:DPTPSRMX
我在vba中写了这段代码:
Dim regklammer As New RegExp
Dim regdcm As New RegExp
Dim matchgklammer As MatchCollection
Dim matchgdcm As MatchCollection
regklammer.Pattern = "\[+\w*\]"
regklammer.Global = True
regdcm.Pattern = "\w*"
'regdcm.Global = True
Set matchgklammer = regklammer.Execute(Pruefhinweis.Value)
For K = 0 To matchgklammer.Count - 1
MsgBox matchgklammer.Item(K)
Set matchgdcm = regdcm.Execute(Trim(matchgklammer.Item(K)))
MsgBox matchgdcm.Item(0)
Next K
但 matchdcm.count 是 4 并且它返回 3 个空格 + DPTPSRMX
。你能告诉我,为什么我的代码会找到空格,我该如何解决这个问题?