xHarbour Reference Documentation > Function Reference |
Tests if a string begins with a search pattern.
WildMatch( <cPattern>, <cString>, [<lFullMatch>] ) --> lFound
The function returns .T. (true) when <cString> contains the search pattern.
WildMatch() is a pattern matching function that searches a string for a search pattern. If the search pattern is found, the function returns .T. (true).
WildMatch() operates similarly to OrdWildSeek() but can be used as part of a SET FILTER condition on an unindexed database.
See also: | $, At(), IN, OrdWildSeek(), SET FILTER |
Category: | Character functions , xHarbour extensions |
Source: | rtl\strmatch.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example demonstrates the pattern matching algorithm employed // by WildMatch() and how the function can be used as filter condition // for a database PROCEDURE Main LOCAL cStr := "The xHarbour compiler" ? WildMatch( "bo?" , cStr, .F. ) // result: .F. ? WildMatch( "bo?" , cStr, .T. ) // result: .F. ? WildMatch( "*bo" , cStr, .F. ) // result: .T. ? WildMatch( "*bo" , cStr, .T. ) // result: .F. ? WildMatch( "The" , cStr, .F. ) // result: .T. ? WildMatch( "The" , cStr, .T. ) // result: .F. ? WildMatch( "The*r", cStr, .F. ) // result: .T. ? WildMatch( "The*r", cStr, .T. ) // result: .T. ? WildMatch( "The?x", cStr, .F. ) // result: .T. ? WildMatch( "The?x", cStr, .T. ) // result: .F. USE Customer SET FILTER TO WildMatch( "W*s", FIELD->LastName ) GO TOP DbEval( {|| QOut( FIELD->LastName ) } ) // Output: Names starting with "W" and ending with "s" // Walters // Waters CLOSE Customer RETURN
http://www.xHarbour.com