返回列表 上一主題 發帖

只取出字串中的中文字元

用 “正規表示式”

Function CountDblChr(ByVal sCh As String) As Integer

    Set re = CreateObject("vbscript.regexp")

    're.Pattern = "[\u4e00-\u9fa5]" '判斷中文字(包括特殊字,但不包括符號。和數字如1)

    re.Pattern = "[^\x00-\xff]" '判斷所有的全形字

    re.Global = True

    re.IgnoreCase = True

    Set matches = re.Execute(sCh)

    CountDblChr = matches.Count

    Set re = Nothing

End Function
ss

TOP

        靜思自在 : 布施如播種,以歡喜心滋潤種子,才會發芽。
返回列表 上一主題