正则表达式找不出匹配内容,求解。
本人写了代码,找不出问题。请各位大神帮忙解决,为什么正则匹配不到合适字符串。目标字符串s内容简单:"快递费21200办公费8120"
代码如下,虽然有问题,自己查不出来。请大神帮忙检查。
感谢!
Option Explicit
Sub regexpDemo()
Dim s$, i&
Dim myReg As Object
Dim myMatches As Object, myMatch As Object
i = 1
s = ""
Do While Cells(i, 1) <> ""
s = s & Cells(i, 1).Value
i = i + 1
Loop
Set myReg = CreateObject("vbscript.regexp")
myReg.Pattern = "\s*(\w+费)(\d+)\s*"
myReg.Global = True
Set myMatches = myReg.Execute(s)
MsgBox myMatches.Count
i = 1
For Each myMatch In myMatches
Cells(i, 2) = myMatch.submatches(0)
Cells(i, 3) = myMatch.submatches(1)
i = i + 1
Next myMatch
End Sub