Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opinions for best way to check a string for invalid Char
Message
 
 
To
22/02/1999 19:35:38
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00189473
Message ID:
00192564
Views:
19
Thanks Paul,
I noticed that pretty quickly. I'm doing exactly what you suggest here. Thanks again for your time.
Marcus.

>If you're going to use this function for large tables, it's good to know that a UDF (user defined function) is much slower than a built-in function. So, a simple chrtran() would be much faster.
>
>Anyway, you can replace the following:
>len(alltrim(chrtran(str2check,validchars,testchars))) = 0
>
>with:
>len(chrtran(str2check,validchars,"")) = 0
>
>Vlad
>
>>Silvio,
>>
>>Thanks for the tip. This is very clever, and will work best for me since I have been given a list of valid characters to deal with. Thanks to everyone for the great tips!
>>
>>Marcus.
>>
>>>Marcus, try
>>>
>>>*function ValidStr
>>>lparameters str2check
>>>local validchars,testchars
>>>validchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "
>>>testchars = space(len(validchars))
>>>return len(alltrim(chrtran(str2check,validchars,testchars))) = 0
>>>
>>>Using validchars as above ValidStr("Silvio") will return .F. while ValidStr(upper("Silvio")) will return .T:
>>>
>>>Just adjust validchars to your needs
>>>
>>>HTH
>>>
>>>Silvio
>>>
>>>>I need to check names and addresses for invalid characters. What do you guys think is the best command/function to use for this. Thanks for your help.
>>>>Marcus.
Previous
Reply
Map
View

Click here to load this message in the networking platform