
Dim oMatches As Object
Dim sText As String
dim myregexp
Set myregexp = CreateObject("vbscript.regexp")
With myregexp
'设置是否匹配所有的符合项,True表示匹配所有, False表示仅匹配第一个符合项
.Global = True
'设置是否区分大小写,True表示不区分大小写, False表示区分大小写
.IgnoreCase = True
'设置要查找的字符模式
.Pattern = "[\u4e00-\u9fa5]+"
'判断是否可以找到匹配的字符,若可以则返回True
MsgBox .Test(sText)
'对字符串执行正则查找,返回所有的查找值的集合,若未找到,则为空
Set oMatches = .Execute(sText)
'把字符串中用正则找到的所有匹配字符替换为其它字符
MsgBox .Replace(sText, "")
End With
Set myregexp= Nothing
Set oMatches = Nothing



