Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Single occurrence in a string
Message
De
27/03/2015 13:44:46
 
 
À
27/03/2015 13:25:38
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:
01617328
Vues:
127
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