How to Use Wildcards in a String Search RoutineID: Q146221 3.00 3.00b WINDOWS
The information in this article applies to:
SUMMARYFoxPro includes several functions, such as AT(), that you can use to determine if a string is contained within another string. However, no native function exists that will use wildcards in the string to be searched for in the larger string. This article shows by example how to search for a string containing wildcards within a larger string.
MORE INFORMATION
Sample CodeFUNCTION wcardfind PARAMETER srchstr, wildcard, longstr STORE LEN(longstr) TO ilongstrlen
STORE LEN(ALLT(srchstr)) TO isrchstrlen
STORE ilongstrlen - isrchstrlen TO ilastoffset
STORE isrchstrlen - LEN(ALLT(STRTRAN(srchstr, wildcard, ""))) ;
STORE .F. TO lfound
STORE (ilongstrlen > isrchstrlen) AND ;
DO WHILE (! isrchoffset > ilastoffset) AND (! lfound) AND ok
ENDDO
RETURN IIF(lfound,ifoundat,0)
Testing the FunctionPlace the following code before the above function in a program file to test the function. The value returned in the wait window should be 4:
Additional reference words: 3.00 3.00b VFoxWin
KBCategory: kbhowto
KBSubcategory: FxprgGeneral
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |