Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
To clean a string
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00454334
Message ID:
00454343
Vues:
28
>>I want a small prog or solution to clean a string which will remove all things execpt numbers and Alphbets.
>
>Here is one way
>
>
>? RemoveSpecial("832i#@^&*ds7fha8732h909&*%$*%9")
>
>FUNCTION RemoveSpecial
>	PARAMETER pcString
>	LOCAL lcNew, i, lcSymbol
>	
>	lcNew = ""
>	* loop through string and remove everything except letters and numbers
>	FOR i = 1 to len(pcString)
                lcSymbol=substr(pcString,i,1) 
>		IF IsDigit(lcSymbol) or IsAlpha(lcSymbol)
>			lcNew = lcNew + substr(pcString,i,1)
>		ENDIF
>	ENDFOR
>RETURN UPPER(lcNew)
>
>
This is if we can not determine in advance all 'bad' characters. Otherwise my solution is simpler for huge strings. Also we can check FoxTools functions: (Filter?, Reduce)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform