#2
山泉水2023-06-01 15:32
|
目标字符串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
只有本站会员才能查看附件,请 登录