4,008
社区成员
发帖
与我相关
我的任务
分享
str ="测试数据其中有123,看能不能找234出这段456话中的连777续3个数字!"
Pattern ="\d{3}"
MsgBox(str)
msg=RegExpGeneral(str,Pattern)
For Each i In msg
If IsEmpty(i) Then
Exit For
End If
MsgBox i
Next
Function RegExpGeneral(TextValue,Pattern)
Dim i
Set RegExpGen = New RegExp
With RegExpGen
.Global = True
'设置Global适用性
.IgnoreCase = True
'设置实例的不灵敏性
.Pattern = Pattern
'模式
Set Matches = .Execute(TextValue)
'执行搜索正则 即形成了数组对象
End With
'定义一个动态数组,来确定其返回的结果长度
Dim MyArraysLenth
ReDim MyArraysLenth(Matches.Count)
For i = 0 To Matches.Count-1
MyArraysLenth(i) = Matches(i).Value
Next
RegExpGeneral = MyArraysLenth
End Function