1
需要找到阵列的任何符号。VBA。用于搜索或替换的阵列
例如: replace(string,[a,b,c,e,f,g],“a1b2c3d4e567”); result =“1234567”
这是怎么回事?
需要找到阵列的任何符号。VBA。用于搜索或替换的阵列
例如: replace(string,[a,b,c,e,f,g],“a1b2c3d4e567”); result =“1234567”
这是怎么回事?
据我所知,你将不得不通过连续调用做到这一点,以取代
result = "a1b2c3d4e567"
result = replace(result,"a","")
result = replace(result,"b","")
result = replace(result,"c","")
等
如果你的目标是消除所有非数字字符,下面的工作:
' Added reference for Microsoft VBScript Regular Expressions 5.5
Const s As String = "a1b2c3d4e567"
Dim regex2 As New RegExp
Dim a As String
regex2.Global = True
regex2.Pattern = "[^0-9]"
Dim a As String = regex2.Replace(s, "")
MsgBox (a) ' Outputs 1234567
如果您正在查找特定字符,请更改该模式。