Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing Spaces from Charter String
Message
De
13/11/1999 10:55:03
 
 
À
12/11/1999 23:01:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00290863
Message ID:
00290928
Vues:
15
>Using VFP6.0 SP3
>
>I'm tring to remove a space from a charter string exp("ABC 12345")
>!ISDIGIT copies the space
>ISDIGIT doen't copy the "ABC"
>
>TIA

Looks like you've found a solution, but I wanted to offer up one of my favorite VFP string functions: CHRTRAN().

YOu can use it to replace all characters in a stringthat match any character in another string with a third expression. In your particular case, you would just:

lcString = CHRTRAN(lcString, " ","")

But you can also do tons of other cool stuff, like remove any invalid characters:

lcString = CHRTRAN(lcString, "~!@#$%^&*?","")

Or getting even more creative, you can remove any character that does not
occur in a given string, so you can filter your string for only valid characters. Say a product code is only supposed to contain the digits 0-9 and the letters A-F, and all other characters should be removed-

lcString = CHRTRAN(lcString, CHRTRAN(lcString, "0123456789ABCDEF",""),"")
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform