Comparison of Characters and Strings
====================================
- Function: char-equal character1 character2
This function returns `t' if the arguments represent the same
character, `nil' otherwise. This function ignores differences in
case if `case-fold-search' is non-`nil'.
(char-equal ?x ?x)
=> t
(let ((case-fold-search nil))
(char-equal ?x ?X))
=> nil
- Function: string= string1 string2
This function returns `t' if the characters of the two strings
match exactly. Case is always significant, regardless of
`case-fold-search'.
(string= "abc" "abc")
=> t
(string= "abc" "ABC")
=> nil
(string= "ab" "ABC")
=> nil
The function `string=' ignores the text properties of the two
strings. When `equal' (Note:Equality Predicates) compares two
strings, it uses `string='.
If the strings contain non-ASCII characters, and one is unibyte
while the other is multibyte, then they cannot be equal. Note:Text Representations.
- Function: string-equal string1 string2
`string-equal' is another name for `string='.
- Function: string< string1 string2
This function compares two strings a character at a time. It
scans both the strings at the same time to find the first pair of
corresponding characters that do not match. If the lesser
character of these 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 according to their character
codes. Keep in mind that lower case letters have higher numeric
values in the ASCII character set than their upper case
counterparts; digits and many punctuation characters have a lower
numeric value than upper case letters. An ASCII character is less
than any non-ASCII character; a unibyte non-ASCII character is
always less than any multibyte non-ASCII character (Note:Text
Representations).
(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
- Function: string-lessp string1 string2
`string-lessp' is another name for `string<'.
- Function: compare-strings string1 start1 end1 string2 start2 end2
&optional ignore-case
This function compares the specified part of STRING1 with the
specified part of STRING2. The specified part of STRING1 runs
from index START1 up to index END1 (`nil' means the end of the
string). The specified part of STRING2 runs from index START2 up
to index END2 (`nil' means the end of the string).
The strings are both converted to multibyte for the comparison
(Note:Text Representations) so that a unibyte string can be
equal to a multibyte string. If IGNORE-CASE is non-`nil', then
case is ignored, so that upper case letters can be equal to lower
case letters.
If the specified portions of the two strings match, the value is
`t'. Otherwise, the value is an integer which indicates how many
leading characters agree, and which string is less. Its absolute
value is one plus the number of characters that agree at the
beginning of the two strings. The sign is negative if STRING1 (or
its specified portion) is less.
- Function: assoc-ignore-case key alist
This function works like `assoc', except that KEY must be a
string, and comparison is done using `compare-strings', ignoring
case differences. Note:Association Lists.
- Function: assoc-ignore-representation key alist
This function works like `assoc', except that KEY must be a
string, and comparison is done using `compare-strings'. Case
differences are significant.
See also `compare-buffer-substrings' in Note: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 Note:Regexp Search.