Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alpha characters in a string
Message
De
12/11/2003 14:56:37
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
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:
00849230
Vues:
23
>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......
>
>Does anyone know a quicker way?
>Thanks,
>Dan

Basically, you can use chrtran(). This can be done in several ways; for instance:
? len(chrtran(alltrim(MyField), "abcdefghijklmnopqrstuvwxyz", "") # len(alltrim(MyField)
That is, all letters (only lowercase, in my example) are wiped out; if the length varies, then there were letters.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform