|
- ''
- Function AddBlank(Str)
- With CreateObject("vbscript.regexp")
- .Pattern = "(""[a-z]+?""|[a-z])"
- .Global = True
-
- AddBlank = .Replace(Str, "$1 ")
- End With
- End Function
- ''
- Function AddBlank1(Str)
- With CreateObject("vbscript.regexp")
- .Pattern = "(""[A-Z]+?""|[A-Z])"
- .Global = True
-
- AddBlank1 = .Replace(Str, "$1 ")
- End With
- End Function
- ''
- Function AddBlank2(Str)
- With CreateObject("vbscript.regexp")
- .Pattern = "(""[0-9]+?""|[0-9])"
- .Global = True
- AddBlank2 = .Replace(Str, "$1 ")
- End With
- End Function
- ''
- Function AddBlank3(Str)
- With CreateObject("vbscript.regexp")
- .Pattern = "(""[一-龥]+?""|[一-龥])" '如果凡是引号内的内容都不加空格,可用
- '(""[^""]+""|[一-龥])
-
- '.Pattern = "(\d+)(?!$)"
- .Global = True
-
- AddBlank3 = .Replace(Str, "$1 ")
- End With
- End Function
- Private Sub ll()
- Dim Str, oStr
- oStr = "汉字添加空格成功FFFabc159eFF"
- Str = AddBlank(oStr)
- Str = AddBlank1(Str)
- Str = AddBlank2(Str)
- Str = AddBlank3(Str)
- Debug.Print Str
- End Sub
复制代码 原字符串
oStr = "汉字添加空格成功FFFabc159eFF"
运行上面代码的结果是:
汉 字 添 加 空 格 成 功 F F F a b c 1 5 9 e F F
|
|