ASP methods for repeating items in the divisor group _ Application techniques

Source: Internet
Author: User

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, ",")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.