vbs 去除字符串中的所有符号
发布网友
发布时间:2024-10-24 13:30
我来回答
共1个回答
热心网友
时间:2024-10-31 00:00
不要那个符号,自己在rule数组里面添加
Option Explicit
Sub test()
Dim s As String
s = "str = ""[系统%+息]玩家King5由5^于在?游戏=中退,经|被-踢:出房&间,希望@大家/引为戒,素)质#和谐[氛围。"""
MsgBox cls(s)
End Sub
Function cls(ByVal str As String) As Variant
Dim rule As Variant
Dim i As Integer
rule = Array("@", "#", "^", "$", "%", "&", "*", "(", ")", "-", "+", "/", "?", "[", "]", ",", "。")
cls = str
For i = LBound(rule) To UBound(rule)
cls = Split(cls, rule(i))
cls = Join(cls, "")
Next i
End Function