|
楼主 |
发表于 2012-6-19 16:54
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Function Execute_test(str As String, pat As String)
Dim S As String
Dim i As Integer
Dim reg As RegExp
Set reg = New RegExp
With reg
.Global = True
.MultiLine = True
.Pattern = pat
Set matchs = .Execute(str)
For Each Match In matchs
S = S & Match
i = i + 1
Next
End With
Execute_test = S & "——共匹配了" & i & "次"
Set reg = Nothing
End Function
实例实测二二: Test测试
Ctp_119 ctp_119 119119——共匹配了15次
Function Test_test(str As String, pat As String)
Dim S As String
Dim i As Integer
Dim reg As RegExp
Set reg = New RegExp
With reg
.Global = True
.MultiLine = True
.Pattern = pat
For i = 1 To VBA.Len(str)
If .Test(VBA.Mid(str, i, 1)) Then S = S & VBA.Mid(str, i, 1)
Next i
End With
Test_test = S & "——共匹配了" & i - 1 & "次"
Set reg = Nothing
End Function
我相信大家通过这么多实例实测加以帮助理解,应该没有什么问题了,剩下的是大家自己去一一变通测试。一定要自己动手哟!
|
|