Comparison functions


Comparison functions can be used in conjunction with global variables to test fields, device names, and other specialized functions. (See next section for a description of global variables.) Comparisons are typically joined with other expressions with logical operators, previously described. Each operator in the following table requires a left and right value.

eq 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 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 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, they are 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 operator 

Similar to the lt operator, except the comparison is less than or equal to. The left and right values must both 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 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 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 right values are not numbers, they are 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 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 the case. 

Example

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

lle 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 to the right value, ignoring the 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 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 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 lge 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 operator

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 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 operator

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.



Related topic

 

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