直接用代码构造函数:
'正则表达式替换文本
Function replaceme(ByVal numx) As String
Dim regx As Object
Set regx = CreateObject("VBScript.RegExp")
Dim mat As Object
Dim m As Object
With regx
.Global = True
' '如果检测内容中含有非字母和非数字则返回"失败"
' .Pattern = "\W"
' Set mat = .Execute(检测内容)
' If mat.Count <> 0 Then
' 替换 = "失败"
' Exit Function
' End If
'替换英文字幕,返回替换后的字符
.Pattern = "[a-zA-Z]"
replaceme = .Replace(numx, "")
'替换对应符号
.Pattern = "[【】{},。,]"
replaceme = .Replace(replaceme, "")
'替换所有汉字
.Pattern = "[一-龥]"
replaceme = .Replace(replaceme, "")
End With
End Function
这样后期可以利用
str1=replaceme(range("a1"))这样的来获得替换后的内容。