String comparison: Difference between revisions
Content added Content deleted
m (→{{header|R}}) |
|||
Line 602: | Line 602: | ||
=={{header|Harbour}}== |
=={{header|Harbour}}== |
||
We will compare two strings, ''s1'' and ''s2''. The following comparisons are case sensitive. |
We will compare two strings, ''s1'' and ''s2''. The following comparisons are case sensitive. |
||
<lang |
<lang visualfoxpro>IF s1 == s2 |
||
? "The strings are equal" |
|||
ENDIF |
|||
IF !( s1 == s2 ) |
|||
? "The strings are not equal" |
|||
ENDIF |
|||
IF s1 > s2 |
|||
? "s2 is lexically ordered before than s1" |
|||
ENDIF |
|||
IF s1 < s2 |
|||
? "s2 is lexically ordered after than s1" |
|||
ENDIF</lang> |
|||
To achieve case insensitive comparisons, we should use Upper() or Lower() functions: |
To achieve case insensitive comparisons, we should use Upper() or Lower() functions: |
||
<lang |
<lang visualfoxpro>IF Upper( s1 ) == Upper( s2 ) |
||
? "The strings are equal" |
|||
ENDIF</lang> |
|||
</lang> |
|||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |