Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alpha characters in a string
Message
From
12/11/2003 14:56:37
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
12/11/2003 14:46:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00849226
Message ID:
00849230
Views:
22
>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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform