LIKE Function

Syntax

Result_Flag as L = LIKE(C string_1,C Character_String_2)

Arguments

string_1

A character string, can include the standard wildcard characters * and ? . * Represents any number of characters, including no characters at all. ? Represents a single character. You can use the wildcard characters more than once anywhere in string_1.

Character_String_2

The character string to compare to string_1. Character

Description

Returns TRUE if all or part of the first string is found in the second string.

Discussion

LIKE() returns .T. (TRUE) if string_1 equals Character_String_2 ; otherwise, it returns .F. (FALSE). This function is extremely useful in filter expressions. It is more flexible than the $ operator because it enables you to search for the occurrence of one string at a specific location within another string. For example, the expression LIKE("super*computer*inc.", LOWER(COMPANY)) is TRUE for all company names that meet the following conditions: Start with "Super" Have the string "computer" anywhere within the name End with "Inc." The Find_String argument is case sensitive.

Example

? like("*a*123", "999a000123")
= .T.
? like("? a*123", "999a000123")
= .F.
? like("*man", "Zimmerman")
= .T.

See Also