PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Remove duplicate characters in string
Remove duplicate characters in string
Iniciado por guest, 15,jun. 2017 17:39 - 5 respuestas
Publicado el 15,junio 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.
Publicado el 15,junio 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
Publicado el 15,junio 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.
Publicado el 15,junio 2017 - 23:14
Hi Art,

it is in a while loop ...
Publicado el 16,junio 2017 - 02:05
Thanks I'll give that a try.
Publicado el 16,junio 2017 - 09:09
Hi Donald,

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

WordToArray(aString,StringArray)

RESULT ArrayToString(StringArray," ")



Regards,
Bart