Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alpha characters in a string
Message
 
 
À
12/11/2003 14:46:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00849226
Message ID:
00849360
Vues:
26
Dan,

If you can approach it the other way around, ie only numeric digits are valid:
#define VALIDCHARACTERS "0123456789.+-"

lcX = "1234.456"
? lcX == chrtran( lcX, chrtran( lcX, VALIDCHARACTERS, "" ), "" ) && .T.

lcX = "1234e456"
? lcX == chrtran( lcX, chrtran( lcX, VALIDCHARACTERS, "" ), "" ) && .f.
this way you don't need to upper() or lower() or include all possible bad characters to look for in your strings. I think in your case it's much easier to define the characters that are considered ok.

>What is the slickest way to figure out if alpha characters are in a string
>such as:
>
>x = "234e593"
>? DoesItContainAlpha(x) && Returns .T.
>
>y = "1345.00"
>? DoesIt ContainAlpha(y) && Returns .F.
>
>I can cycle through the whole alphabet and see if one of the
>characters are contained in the string, but that seems to
>long......
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform