Zum Hauptinhalt gehen

Suche

Suche

Remove duplicates in string

Kommentare

2 Kommentare

  • Avatar
    KM3

    You can (probably) do this using regular expression (RegEx). However, I'm not skilled enough that I could simply provide the code for it, however, it's actually not too complicated and you can probably figure it out on your own - start reading up here: https://msdn.microsoft.com/en-us/library/6wzad2b2(v=vs.84).aspx

    Essentially, you're trying to match two identical characters followed by a space but only, when followed by another pair of those identical characters. You need to figure out what's called the "Pattern", to match this scenario, then let RegEx "do the rest"

    0
  • Avatar
    Erwin Chu

    Thanks for your input KM3

    I was actually able to find a script and modify it for my needs.

    Dim varSection
    Dim sTemp
    sDelimiter = " "
    For Each varSection In Split(Value, sDelimiter)
    If InStr(1, sDelimiter & sTemp & sDelimiter, sDelimiter & varSection & sDelimiter, vbBinaryCompare) = 0 Then
    sTemp = sTemp & sDelimiter & varSection
    End If
    Next

    Value = Mid(sTemp, Len(sDelimiter) + 1)

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.