String Comparison Functions
AMPS includes several types of string comparison operators:
Case-Sensitive Exact Matches - The
IN
,=
,BEGINS WITH
,ENDS WITH
, andINSTR
operators do literal matching on the contents of a string. These operators are case-sensitive.Case-Insensitive Exact Matches - AMPS also provides two case-insensitive operators:
INSTR_I
, a case-insensitive version ofINSTR
, and a case-insensitive equality operator,STREQUAL_I
.Regular Expression Matches - AMPS also provides full regular expression matching using the
LIKE
operator, described in Regular Expressions.
The =
operator tests whether a field exactly matches the literal string provided.
BEGINS WITH
and ENDS WITH
test whether a field begins or ends with the literal string provided. The operators return TRUE
or FALSE
.
AMPS allows you to use set comparisons with BEGINS WITH
and ENDS WITH
. In this case, the filter matches if the string in the field begins or ends with any of the strings in the set.
The INSTR
operator allows you to check to see if one string occurs within another string. For this operator, you provide two string values. If the second string occurs within the first string, INSTR
returns the position at which the second string starts, or 0 if the second string does not occur within the first string. Notice that the first character of the string is 1 (not 0). For example, the expression below tests whether the string critical
occurs within the /eventLevels
field.
AMPS also provides INSTR_I
and STREQUAL_I
functions for performing case-insensitive comparisons.
The following table lists the string comparison functions and operators in AMPS:
=
The string to be compared
The string to compare
Case-sensitive
Returns true if the string to be compared is identical to the string to compare.
BEGINS WITH
The string to be compared
A list of strings to compare
Case-sensitive
Returns true if the string to be compared begins with any of the strings in the list.
ENDS WITH
The string to be compared
A list of strings to compare
Case-sensitive
Returns true if the string to be compared ends with any of the strings in the list.
INSTR
The string to be compared
The string to compare
Case-sensitive
Returns the position at which the second string starts, or 0 if the second string does not occur within the first string.
This function is not unicode-aware.
INSTR_I
The string to be compared
The string to compare
Case-insensitive
Returns the position at which the second string starts, or 0 if the second string does not occur within the first string.
This function is not unicode-aware.
STREQUAL_I
The string to be compared
The string to compare
Case-insensitive
Returns true if, when both strings are transformed to the same case, the string to be compared is identical to the string to compare.
This function is not unicode-aware.
LENGTH
The string to be counted
Returns the length of the provided string.
Last updated