PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Remove duplicate characters in string
Remove duplicate characters in string
Débuté par Donald Montaine, 15 juin 2017 17:39 - 5 réponses
Posté le 15 juin 2017 - 17:39
Before I write my own routine, is there a function available that will remove duplicate characters from a string. I want to make sure that there is only a single space between words in a string.
Posté le 15 juin 2017 - 18:13
Hi Donald,

Something like this (not tested)?

While stringcount(YourString," ")
YourString = Replace(YourString," "," ") // First " " are 2 spaces, the 2nd " " 1 space
END
Posté le 15 juin 2017 - 22:44
Quote
Stefan Bentvelsen



While stringcount(YourString," ")

YourString = Replace(YourString," "," ") // First " " are 2 spaces, the 2nd " " 1 space

END

That would probably miss the cases where there are 3+ spaces. Might have to put it in a loop for x amount of times to catch them all.
Posté le 15 juin 2017 - 23:14
Hi Art,

it is in a while loop ...
Posté le 16 juin 2017 - 02:05
Thanks I'll give that a try.
Posté le 16 juin 2017 - 09:09
Hi Donald,

FUNCTION RemoveMultipleSpaces(aString is string)
StringArray is array of strings

WordToArray(aString,StringArray)

RESULT ArrayToString(StringArray," ")



Regards,
Bart