|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 422566739 于 2019-8-17 11:10 编辑
添加一个正则函数
Public Function vbaRegExp(ByVal s, patt, Optional ByVal newText = "newTextfalse")
Dim arr()
Set reg = CreateObject("VBScript.RegExp")
With reg
.Global = True
.IgnoreCase = True
.Pattern = "" & patt & ""
If newText = "newTextfalse" Then
Set Mac = .Execute(s)
ReDim arr(1 To Mac.Count)
n = 0
For Each i In Mac
n = n + 1
arr(n) = i
Next i
vbaRegExp = arr
Else
Let res = .Replace(s, newText)
vbaRegExp = res
End If
End With
End Function
|
评分
-
1
查看全部评分
-
|