411 REFERENCE · Wikibooks
Rexx Programming/How to Rexx/string comparison
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
String comparisons are made based upon lexical string order
String operators make comparisons based upon the lexical string order. Strings listed first in lexical order have a lower comparative value than strings listed later.
Supported operators
The following example shows a string comparison being made using the comparative operators:
animal = 'dog'
if animal > 'cat' then
say animal "is lexically higher than cat"
The following comparative operators are supported:
= Equal To
\= Not Equal To
< Less Than
> Greater Than
<= Less Than or Equal To
>= Greater Than or Equal To
\< Not Less Than
\> Not Greater Than
<> Not Equal To
>< Not Equal To
Conventional string comparative operators ignore leading and trailing whitespace
The conventional string comparison operators ignore leading and trailing whitespace when the comparison is made:
' ' = '' /* 1 true, string comparison (stripped whitespace matches null value) */
'ABC' = ' ABC ' /* 1 true, string comparison (leading and trailing whitespace ignored) */
Strict Comparison
The strict comparative operators do not ignore leading and trailing whitespace, which must also match when a strict comparison is made:
' ' == '' /* 0 false, strict comparison (the spaces will not match the null value) */
'ABC' == ' ABC ' /* 0 false, strict comparison (leading and trailing whitespace causes mismatch) *# /