Rexx 编程/Rexx 指南/字符串比较
外观
字符串操作符基于词典字符串顺序进行比较。在词典顺序中排在前面的字符串具有比排在后面的字符串更低的比较值。
以下示例展示了使用比较操作符进行字符串比较。
animal = 'dog' if animal > 'cat' then say animal "is lexically higher than cat"
= 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
传统的字符串比较操作符在进行比较时会忽略开头和结尾的空白字符。
' ' = /* 1 true, string comparison (stripped whitespace matches null value) */ 'ABC' = ' ABC ' /* 1 true, string comparison (leading and trailing whitespace ignored) */
严格的比较操作符不会忽略开头和结尾的空白字符,在进行严格比较时,这些空白字符也必须匹配。
' ' == /* 0 false, strict comparison (the spaces will not match the null value) */ 'ABC' == ' ABC ' /* 0 false, strict comparison (leading and trailing whitespace causes mismatch) *# /