Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Single occurrence in a string
Message
From
27/03/2015 16:15:33
 
 
To
27/03/2015 13:44:46
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01617326
Message ID:
01617336
Views:
91
Thanks to all (Dragan, Marcia and Tore). I wonder which solution is the fastest?

>How do I remove duplicate characters in a string:
>
>
>Bigstring = 'cattttccv'
>NonDupeString = NonDupe(BigString)
>
>* Result = 'catv'
>

>
>
>Bigstring = 'cattttccv'
>NonDupeString = NonDupe(BigString)
>?NonDupeString
>
>FUNCTION NonDupe(tcString)
>LOCAL lcNewString, lnI, lnLen, lcChar
>lcNewString = tcString
>lnLen = LEN(tcString)
>lnI = 1
>DO WHILE lnI < lnLen
>	lcChar = SUBSTR(lcNewString, lnI, 1)
>	IF OCCURS(lcChar, lcNewString) > 0
>		lcNewString = STRTRAN(lcNewString, lcChar, '', 2, -1, 2)
>		lnLen = LEN(lcNewString)
>	ENDIF 
>	lnI = lnI + 1 
>ENDDO 
>RETURN lcNewString
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform