Here's one that I would bet is the fastest :)
*-- Build a list of invalid chars
* Obviously, this can be done only once.
gcInvalidChars = ""
for i = 0 to 255
if not between(chr(i), "A", "Z") and ;
not between(chr(i), "a", "z") and ;
not between(chr(i), "0", "9")
gcInvalidChars = gcInvalidChars + chr(i)
endif
endfor
*-- If you want to test if a string contains invalid chars:
if (len(lcString) <> len(chrtran(lcString, gcInvalidChars, "")))
*-- Do whatever
endif
*-- If you want to filter a string:
lcFilteredString = chrtran(lcString, gcInvalidChars, "")
Note: Use chrtran() whenever possible. It's faster than strtran() and, it's MUCH faster than a loop through all the chars in a string.
Vlad
>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only