Class CNWORD
Public Str Private Sub class_initialize () set regex = new regexp regex.ignorecase = true 'Set whether you are case sensitive. Regex.global = true 'Sets global availability. End Sub
Private regex
Property Get CN (X) DIM Arr () Dim MaxBound: maxbound = cnblockcount Redim Arr (MaxBound) DIM i: i = 1 for Each Match in Regex.execute (STR) Arr (i) = Match i = i 1 Next IF X <= maxbound the cn = arr (x) End Property
Property get cncount 'Returns the number of words containing Chinese regex.pattern = "[/ u4e00- / u9fa5]" cncount = findchnnum () End Property
Property Get CNBLOCKCOUNT 'Returns Regex.pattern = "[/ U4E00- / U9FA5] " CNBLOCKCOUNT = FINDCHNNUM () End Property
Private function Findchnnu () Findchnnum = regex.execute (str) .count end function private sub class_terminate () set regex = Nothing end sub
END CLASS
Set ccc = new cnword ccc.str = "CNWORD class reference instance, VBS" msgbox "contains Chinese" & ccc.cncount msgbox "contains Chinese blocks" & ccc.cnblockcount msgbox "2nd Chinese block "-> & Ccc.cn (2)
Set ccc = nothing script>