|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 liu-aguang 于 2021-2-9 19:07 编辑
- Sub test()
- S = "Dim reg As New RegExp, a As Workbook" & vbLf & "Dim i2$, j2&, k2#"
- Set regx = CreateObject("vbscript.regexp")
- regx.Pattern = "\b(?:Public|Private|Static|Const|Dim)\b(.+)"
- regx.IgnoreCase = True
- regx.Global = True
- Set mh = regx.Execute(S)
- regx.Pattern = "(\w+)[^,]*"
- For Each mhs In mh
- Set mh1 = regx.Execute(mhs.submatches(0))
- For Each k In mh1
- MsgBox k.submatches(0)
- Next
- Next
- End Sub
复制代码 |
|