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) *# /