Function Like() Foundation

Determines if a character expression matches another character expression.

Syntax
Like( <cSkeletonExpr> , <cExpression> ) --> lMatch
Parameters
<cSkeletonExpr>
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>.
<cExpression>
Specifies the character expression to compare to the skeleton string <cSkeletonExpr>
Return

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

Description

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().

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

PROCEDURE Main 
  ? 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. 
RETURN 
Feedback

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.