Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Alpha characters in a string
Message
 
 
To
12/11/2003 14:46:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00849226
Message ID:
00849360
Views:
25
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
Previous
Reply
Map
View

Click here to load this message in the networking platform