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



*******************************************
Scott Goelzer
Physics Teacher
Coe-Brown Northwood Academy
Northwood NH 03261
[EMAIL PROTECTED]
*******************************************



_______________________________________________
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>

Reply via email to