Copy Code code as follows:
<%
Function MoveR (RSTR)
Dim I,spstr
Spstr = Split (Rstr, ",")
For i = 0 to Ubound (SPSTR)
If I = 0 Then
MoveR = MoveR & Spstr (i) & ","
Else
If InStr (Mover,spstr (i)) =0 and I=ubound (SPSTR) Then
MoveR = MoveR & Spstr (i)
Elseif InStr (Mover,spstr (i)) =0 Then
MoveR = MoveR & Spstr (i) & ","
End If
End If
Next
End Function
Response.Write MoveR ("Abc,abc,dge,gcg,dge,gcg,die,dir,die")%>
The result: Abc,dge,gcg,die,dir
If two arrays are compared, remove the same array elements:
Copy Code code as follows:
<%
Function Mover (farray,sarray)
A = Split (Farray, ",")
Set dic = CreateObject ("Scripting.Dictionary")
For K=0 to UBound (a)
If A (k) <> "" Then dic. Add "_" & A (k), a (k)
Next
A = Split (Sarray, ",")
For K=0 to UBound (a)
If A (k) <> "" Then
If DiC. Exists ("_" & A (k)) Then
Dic. Remove "_" & A (k)
End If
End If
Next
Items = dic. Items ()
Set dic = Nothing
Mover=join (Items, ",")
End Function
N1 = "a,b,1,11,12,13,14,15,16,17,19,20,22"
N2 = "a,1,12,14,18,19,20"
Response.Write Mover (N1,N2)
%>
The result:
3. There are empty elements in array a (such as A=array ("ww", "SS", "", "DD", "", "ee")),
You want to remove these empty elements from array A and assign an array of empty elements to array B.
Copy Code code as follows:
Str= ""
For i = LBound (a) To UBound (a)
If A (i) <> "" Then
If I<>lbound (A) then str = str + "," End If
str = str & A (i)
End If
Next
b = Split (str, ",")