like operator
Use the like operator
to compare a string to
a regular expression. The regular expressions available with like include
wildcard and escape characters. The like operator
resembles the LIKE keyword in SQL. For more robust regular expressions,
see matches operator. The operator makes
the comparison character
by character, left to right, and ends when one of the following conditions
is met:
- a character in the source string fails to match a position in the regular expression (comparison is false)
- one string ends but the other does not (comparison is false)
- both strings end (comparison is true)
Syntax

- string
- A STRING variable to compare to a regular expression.
- regEx
- A regular expression to compare string to. The regular expression can be any literal or variable that is assignment compatible with STRING, except for DBCHAR. (EGL cannot recognize double byte wildcard characters.) For more information, see "Regular expression rules" in this topic.
Regular expression rules
You
can include any of the following special characters in a regular expression
with the like operator:
- %
- Acts as a wildcard, matching zero or more characters in the source string.
- _ (underscore)
- Acts as a wildcard, matching a single character in the source string.
- \ (backslash)
- Indicates that the next character is to be compared to a single character in the source string. The backslash (\) is called an escape character because it causes an escape from the usual processing; the escape character is not compared to any character in the source string. The escape character usually precedes a percent sign (%), an underscore (_), or another backslash.
Any other character in the regular expression is a literal that is compared to a single character in the source string.
Examples
The
following example uses wildcards in a regular expression:
myVar01 = "abcdef";
// evaluates as TRUE
if (myVar01 like "a_c%")
;
endThe following example shows the use of an escape
character. Note the use
of doubled backslashes:
myVar01 = "ab%def";
// evaluates as true
if (myVar01 like "ab\\%def")
;
end The following example uses the escape keyword
to make the plus sign the escape character for the regular expression:
myVar01 = "ab%def";
// evaluates as true
if (myVar01 like "ab+%def" escape "+")
;
endThe like operator
ignores trailing blanks in
both operands:
// evaluates as true
if ("hello " like "hello ")
;
end