Comparison operators


The previous section introduces comparison operators that can be used to compare a particular word in the message with another word. These operators permit expressions such as (leftvalue operator rightvalue), returning either true or false.

While the outer parentheses can sometimes be omitted from the comparison expression (depending on where the comparison actually appears in the expression), it is a good practice to include parentheses to promote readability of the expression.

The following operators are available for use with field specifications or global variables:

  • eq Equal operator—The left value must be precisely equal to the right value, ignoring any letter case.

    Example

    The expression  ($4 eq test) returns true if the fourth word of the message is test or TEST, but not TestCase. Likewise, the expression ($2 eq $5) returns true if the second and fifth words are the same in the message. The comparison is case insensitive and wildcards are treated as ordinary characters.

  • ne Not equal operator—The left value must be different from the right operator, ignoring any letter case.

    Example

    The expression  ($4 ne test) returns false if the fourth word of the message is not test or Test, but returns true if the fourth word is TestCase. Likewise, the expression ($2 ne $5) returns false if the second and fifth words are the same in the message. The comparison is case insensitive and wildcards are treated as ordinary characters.

  •  lt Numeric less than operator—The left and right values must both be numbers, or begin with numbers. Returns true if the left value is less than the right value. If either the left or the right value is not a number, it is regarded as a numeric zero.

    Example

    The expression ($4 lt 199) returns true if the fourth word of the message is numerically less than 199, or if the fourth word of the message is not a number.

  •  le Numeric less than or equal to operator—Similar to the lt operator, except the comparison is less than or equal to. Both, the left and the right values, must be numbers, or begin with numbers. Returns true if the left value is less than or equal to the right value. If either the left or right values are not numbers, they are regarded as a numeric zero.

    Example

    The expression ($4 le 199) returns true if the fourth word of the message is 199 or less, or if the fourth word of the message is not a number.

  •  gt Numeric greater than operator—The left and right values must both be numbers, or begin with numbers. Returns true if the left value is greater than the right value. If either the left or right values are not numbers, they are regarded as a numeric zero.

    Example

    The expression ($4 gt 199) returns true if the fourth word of the message is numerically greater than 199, and is also a number.

  •  ge Numeric greater than or equal to operator—Similar to the gt operator, except the comparison is greater than or equal to. The left and right values must both be numbers, or begin with numbers. Returns true if the left value is greater than or equal to the right value. If either the left or  the right value is not a number, it is regarded as a numeric zero.

    Example

    The expression ($4 ge 199) returns true if the fourth word of the message is 199 or greater and is also a number.

  • llt Lexical less than operator—This performs an alphabetical comparison of the left and right values. Returns true if the left value is alphabetically less than the right value, ignoring case.

    Example

    The expression ($1 llt T) returns true if the fourth word of the message is success or Success and returns false if the fourth word is testcase, Test, or workgroup.

  • lle Lexical less than or equal to operator—Similar to the llt operator, except the comparison is alphabetically less than or equal to. Returns true if the left value is alphabetically less than or equal the right value, ignoring case.

    Example

    The expression ($1 lle T) returns true if the fourth word of the message is success or TEST and returns false if the fourth word is workgroup or Workgroup.

  • lgt Lexical greater than operator—This performs an alphabetical comparison of the left and right values. Returns true if the left value is alphabetically greater than the right value, ignoring the case. 

    Example

    The expression ($1 lgt T) returns true if the fourth word of the message is workgroup or Workgroup and returns false if the fourth word is testcase or success.

  • lge Lexical greater than or equal to operator—Similar to the lgt operator, except that the comparison is alphabetically greater than or equal to.  Returns true if the left value is alphabetically greater than or equal the right value, ignoring the case.

    Example

    The expression ($1 lgt T) returns true if the fourth word of the message is test or TEST or Workgroup and returns false if the fourth word is success or Success.

  • in Keyword or wildcard match pattern—This operator tests to see if the keyword or wildcard contained in the left value is found in the right value. This is similar to the correlation expressions discussed previously, but is confined to the value contained in the right value.

    Example

    The expression (key in $5) returns true if the fifth word of the message is key, keyword or PASSKEY. Likewise, the left value can contain wildcards. For instance, the expression (key*o*d in $3) matches the third word if it is Keyword or keyboard.

  • not in Keyword or wildcard match pattern negation—The same as the in operator, except that the comparison returns true if the left value keyword or wildcard is not in the right value. 

    Example

    The expression (key not in $5) returns false if the fifth word of the message is key, keyword or PASSKEY, and the expression (key*o*d not in $3) returns false if the third word if it is Keyword or keyboard.

    Note

    This is the only comparison function containing two separate words. 

Comparison functions allow you to target very specific portions of the target message. As with other expressions, comparisons can be joined together using logical operators to create very specific match patterns.

Example

A typical expression might be ($1 eq Test)  and ( (Key in $5) or not Failure). This pattern matches a message where the first word of the message is test, and either the fifth word of the message contains the string key, or the word failure does not appear anywhere in the message.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*