Operators¶
The valid TCL operators are listed below, grouped in decreasing order
of precedence.
Operand | Description |
|
Unary minus, unary plus, bit-wise NOT, logical NOT. None of these operators may be applied to string operands, and bit-wise NOT may be applied only to integers. |
* / % | Multiply, divide, remainder. None of these operators may be applied to string operands, and remainder may be applied only to integers. The remainder will always have the same sign as the divisor and an absolute value smaller than the divisor. |
Add and subtract. Valid for any numeric operands. | |
<< >> | Left and right shift. Valid for integer operands only. A right shift always propagates the sign bit. |
< > <= >= | Boolean less, greater, less than or equal, and greater than or equal. Each operator produces 1 if the condition is true, 0 otherwise. These operators may be applied to strings as well as numeric operands, in which case string comparison is used. |
== != | Boolean equal and not equal. Each operator produces a zero/one result. Valid for all operand types. |
eq ne | Boolean string equal and string not equal. Each operator produces a zero/one result. The operand types are interpreted only as strings. |
& | Bit-wise AND. Valid for integer operands only. |
^ | Bit-wise exclusive OR. Valid for integer operands only. |
| | Bit-wise OR. Valid for integer operands only. |
&& | Logical AND. Produces a 1 result if both operands are non-zero, 0 otherwise. Valid for boolean and numeric (integers or floating-point) operands only. |
|| | Logical OR. Produces a 0 result if both operands are zero, 1 otherwise. Valid for boolean and numeric (integers or floating-point) operands only. |
x?y:z | If-then-else, as in C. If x evaluates to non-zero, then the result is the value of y. Otherwise the result is the value of z. The x operand must have a boolean or numeric value. |
In addition to the TCL operators above, the following operators have
been added for use within iRules:
Operand | Description |
contains | Tests if one string contains another string |
ends_with | Tests if one string ends with another string |
equals | Tests if one string equals another string |
matches_glob | Implement glob style matching within a comparison |
matches_regex | Tests if one string matches a regular expression |
starts_with | Tests if one string starts_with another string |
switch | Evaluates one of several scripts, depending on a given value |
and | Performs a logical “and” comparison between two values |
not | Performs a logical “not” on a value |
or | Performs a logical “or” comparison between two values |
The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.