Here's one alternative execution:
Function RemoveDuplicates(src As String, delimiter As String) As String
dim s(-1) As String
dim i, u As Integer
dim found As Integer
s = Split(src, delimiter)
u = UBound(s)
for i = u DownTo 0
found = s.IndexOf(s(i))
if found < i and found >= 0 then
While i <= UBound(s) and s.IndexOf(s(i)) < i and found >= 0
s.Remove found
Wend
end if
next
Return Join(s, delimiter)
End Function
On 9/2/06, Scott Goelzer <[EMAIL PROTECTED]> wrote:
Hi All
I know there is a way to do this faster and better than what I
chunked together.
I need a to take a delimited list and remove all duplicate instances.
Anyway to do this faster with Regex? Still very new to me and
somewhat daunting.
Thanks
Scott
Function removeDuplicates(sourceString as string,delim as string) As
string
// We need to produce a string where none of the items are
duplicated.
dim n,i As integer
dim finalString As String
dim sourceArray(-1) As string
dim currentItem As string
sourceArray = Split(sourceString,delim)
for n = 0 to Ubound(sourceArray)
currentItem = sourceArray(n)
if currentItem <> "" then
finalString = finalString + currentitem + delim
sourceArray(n) = ""
for i = n to Ubound(sourceArray)
if sourceArray(i) = currentItem then
sourceArray(i) = ""
end if
next
end if
next
if right(finalString,len(delim)) = delim then
finalString = Left(finalString, len(finalString)-len(delim))
end if
return finalString
End Function
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>