Function Like() Foundation

Determines if a character expression matches another character expression.

Like( <cSkeletonExpr> , <cExpression> ) --> lMatch
Specifies the character expression the function Like( ) compares with <cExpression>. <cSkeletonExpr> can contain wildcards such as * and ?. The question mark (?) matches any single character in <cExpression> and the asterisk (*) matches any number of characters. Any number of wildcards in any combination can be mixed in <cSkeletonExpr>.
Specifies the character expression to compare to the skeleton string <cSkeletonExpr>

The function Like() returns .T. (true) if cExpression matches a specified skeleton string <cSkeletonExpr>. Otherwise the function Like() returns .F. (false).


The function Like() is used to compare one string to another. The skeleton string <cSkeletonExpr> contains wildcard characters and represents a pattern; the <cExpression> string compared to this pattern.

The wildcard character * and ? form a pattern for <cSkeletonExpr>. An asterisk (*) stands for any number of characters, including zero characters. The question mark (?) stands for any single character. Wildcard characters can stand for uppercase and lowercase characters. The comparison is case sensitive. Use Upper() or Lower() for case insensitive comparisons with Like().

// The example shows various results of the function Like() 

  ? Like( "a*d" , "abcd" )      // result: .T. 
  ? Like( "a*d" , "aBCd" )      // result: .T. 

  ? Like( "M?yer" , "Mayer" )   // result: .T. 
  ? Like( "M?yer" , "Meyer" )   // result: .T. 
  ? Like( "M?yer" , "Meier" )   // result: .F. 

  ? Like( "M*er" , "Mayer" )    // result: .T. 

  ? Like( "M??er" , "Mayer" )   // result: .T. 
  ? Like( "M??er" , "Mueller" ) // result: .F. 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.