Array deduplication [VBS]


Function quchongfu(srcstr,ig,sp)
 Dim objDict,x,y
 srcarr=split(Trim(srcstr),sp)
 Set objDict=createobject("Scripting.Dictionary")
 For Each x In srcArr
  If x<>"" Then
   If ig=True  Then
    y=LCase(x)
   Else
    y=x
   End If
   If Not objDict.Exists(y) Then objDict.Add x,y
  End If
 Next
 x=Join(objDict.Items,sp)
 If Right(x,1)=sp Then
  quchongfu=left(x,Len(x)-1)
 Else
  quchongfu=x
 End If
 Set objDict=Nothing
End Function
 
MsgBox quchongfu("aaa,sss,,,AAA,ccc,aaa,AAA,ZZZ,ssssss,,",true,",")

Reproduced in: https: //www.cnblogs.com/aspphpvbs/archive/2013/04/21/3034282.html

Guess you like

Origin blog.csdn.net/weixin_33825683/article/details/93701728