'*************************************** *************
'Function name: StrLen
'Usage: get the string length (2 Chinese characters)
'Parameter: str ---- string content
'Return value: string length
'*************************************** *************
Function StrLen (Str)
Set rep = New regexp
Rep. Global = True
Rep. IgnoreCase = True
Rep. Pattern = "[^ \ x00-\ xff]"
StrLen = Len (Str) + rep. Execute (Str). Count
Set Rep = Nothing
End Function
'*************************************** *************
'Function name: StrLeft
'Usage: get a specified number of strings from the left (Chinese character: 2)
'Parameter: L ---- Number of characters
'Return value: string
'*************************************** *************
Function Strleft (Str, L)
Dim I, Test_Str, lens, tStr, nStr, tL
TStr = Left (Str,-Int (-(L/2 )))
NStr = Right (Str, Len (Str)-Len (tStr ))
If Len (nStr)> 0 Then tL = L-StrLen (tStr)
If Asc (Left (tStr, 1) <0 And Len (tStr) = 1 And L <2 Then tStr = ""
If tL> = 1 Then
Strleft = tStr & Strleft (nStr, tL)
Else
Strleft = tStr
End If
End Function
'*************************************** *************
'Function name: StrRight
'Usage: Get the specified number of strings (2 Chinese characters) from the right)
'Parameter: L ---- Number of characters
'Return value: string
'*************************************** *************
Function StrRight (Str, L)
Dim I, Test_Str, lens, tStr, nStr, tL
TStr = Right (Str,-Int (-(L/2 )))
NStr = Left (Str, Len (Str)-Len (tStr ))
If Len (nStr)> 0 Then tL = L-StrLen (tStr)
If Asc (Left (tStr, 1) <0 And Len (tStr) = 1 And L <2 Then tStr = ""
If tL> = 1 Then
StrRight = StrRight (nStr, tL) & tStr
Else
StrRight = tStr
End If
End Function
'*************************************** *************
'Function name: StrMid
'Usage: specify the start position to obtain the specified number of strings (2 Chinese characters)
'Parameter: the number of S-start strings, and the number of L-characters
'Return value: string
'*************************************** *************
Function StrMid (Str, S, L)
StrMid = strleft (Right (Str, Str Len (Str)-Len (strleft (Str, s) + 1), L)
End Function