Like() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns TRUE or FALSE to indicate whether a string satisfies pattern-matching criteria. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Like( string, pattern_string, escape_char ) 

string is a string expression to test.

pattern_string is a string that contains regular characters or special wild-card characters.

escape_char is a string expression defining an escape character. Use an escape character (for example, "\") if you need to test for the presence of one of the wild-card characters ("%" and "_") in the string expression. If no escape character is desired, use an empty string ("").

Return Value

Logical value (TRUE if string matches pattern_string).

Description

The Like() function performs string pattern-matching. This string comparison is case-sensitive; to perform a comparison that is case-insensitive, use the Like operator.

The pattern_string parameter can contain the following wildcard characters:

_ (underscore) matches a single character.
% (percent) matches zero or more characters.

To search for instances of the underscore or percent characters, specify an escape_char parameter, as shown in the table below.

To determine if a string... Specify these parameters:
starts with "South"
Like( string_var, "South%", "")
ends with "America"
Like( string_var, "%America", "")
contains "ing" at any point
Like( string_var, "%ing%", "" )
starts with an underscore
Like( string_var, "\_%", "\")

See Also:

Len() function, StringCompare() function