更新时间:2023-12-03 18:11:34
使用简单的 regexp ,以保持您所需的字符(即删除不是 az
, AZ
或空格)
Use a simple regexp like this to keep your desired characters (ie remove anything that is not a-z
, A-Z
or a space)
更新:修改为 -
与 / code> before regexp剥离
Function StripNonAlpha(TextToReplace As String) As String
Dim ObjRegex As Object
Set ObjRegex = CreateObject("vbscript.regexp")
With ObjRegex
.Global = True
.Pattern = "[^a-zA-Z\s]+"
StripNonAlpha = .Replace(Replace(TextToReplace, "-", Chr(32)), vbNullString)
End With
End Function