Next: String Conversion, Previous: Character Codes, Up: Strings and Characters [Contents][Index]
This function returns t
if the arguments represent the same
character, nil
otherwise. This function ignores differences
in case if the value of case-fold-search
is non-nil
in
buffer, which defaults to the current buffer.
(char-equal ?x ?x) ⇒ t (let ((case-fold-search t)) (char-equal ?x ?X)) ⇒ t (let ((case-fold-search nil)) (char-equal ?x ?X)) ⇒ nil
This function returns t
if the arguments represent the same
character, nil
otherwise. Case is significant.
(char= ?x ?x) ⇒ t (char= ?x ?X) ⇒ nil (let ((case-fold-search t)) (char-equal ?x ?X)) ⇒ nil (let ((case-fold-search nil)) (char-equal ?x ?X)) ⇒ nil
This function returns t
if the characters of the two strings
match exactly; case is significant.
(string= "abc" "abc") ⇒ t (string= "abc" "ABC") ⇒ nil (string= "ab" "ABC") ⇒ nil
string-equal
is another name for string=
.
This function compares two strings a character at a time. First it
scans both the strings at once to find the first pair of corresponding
characters that do not match. If the lesser character of those two is
the character from string1, then string1 is less, and this
function returns t
. If the lesser character is the one from
string2, then string1 is greater, and this function returns
nil
. If the two strings match entirely, the value is nil
.
Pairs of characters are compared by their ASCII codes. Keep in mind that lower case letters have higher numeric values in the ASCII character set than their upper case counterparts; numbers and many punctuation characters have a lower numeric value than upper case letters.
(string< "abc" "abd") ⇒ t (string< "abd" "abc") ⇒ nil (string< "123" "abc") ⇒ t
When the strings have different lengths, and they match up to the
length of string1, then the result is t
. If they match up
to the length of string2, the result is nil
. A string of
no characters is less than any other string.
(string< "" "abc") ⇒ t (string< "ab" "abc") ⇒ t (string< "abc" "") ⇒ nil (string< "abc" "ab") ⇒ nil (string< "" "") ⇒ nil
string-lessp
is another name for string<
.
See also compare-buffer-substrings
in Comparing Text, for
a way to compare text in buffers. The function string-match
,
which matches a regular expression against a string, can be used
for a kind of string comparison; see Regexp Search.
Next: String Conversion, Previous: Character Codes, Up: Strings and Characters [Contents][Index]