Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Single occurrence in a string
Message
De
27/03/2015 16:15:33
 
 
À
27/03/2015 13:44:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01617326
Message ID:
01617336
Vues:
89
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
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform