This function returns
t if the arguments represent the same
nil otherwise. This function ignores differences
in case if
case-fold-search is non-
(char-equal ?x ?x) ⇒ t (let ((case-fold-search nil)) (char-equal ?x ?X)) ⇒ nil
This function returns
t if the characters of the two strings
match exactly. Symbols are also allowed as arguments, in which case
the symbol names are used. Case is always significant, regardless of
This function is equivalent to
equal for comparing two strings
(see Equality Predicates). In particular, the text properties of
the two strings are ignored; use
you need to distinguish between strings that differ only in their text
properties. However, unlike
equal, if either argument is not a
string or symbol,
string= signals an error.
(string= "abc" "abc") ⇒ t (string= "abc" "ABC") ⇒ nil (string= "ab" "ABC") ⇒ nil
For technical reasons, a unibyte and a multibyte string are
equal if and only if they contain the same sequence of
character codes and all these codes are either in the range 0 through
127 (ASCII) or 160 through 255 (
However, when a unibyte string is converted to a multibyte string, all
characters with codes in the range 160 through 255 are converted to
characters with higher codes, whereas ASCII characters
remain unchanged. Thus, a unibyte string and its conversion to
multibyte are only
equal if the string is all ASCII.
Character codes 160 through 255 are not entirely proper in multibyte
text, even though they can occur. As a consequence, the situation
where a unibyte and a multibyte string are
equal without both
being all ASCII is a technical oddity that very few Emacs
Lisp programmers ever get confronted with. See Text Representations.
string-equal is another name for
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
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
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 (see 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
Symbols are also allowed as arguments, in which case their print names are used.
string-lessp is another name for
This function returns non-
nil if string1 is a prefix of
string2; i.e., if string2 starts with string1. If
the optional argument ignore-case is non-
comparison ignores case differences.
This function returns non-
nil if suffix is a suffix of
string; i.e., if string ends with suffix. If the
optional argument ignore-case is non-
nil, the comparison
ignores case differences.
This function compares a specified part of string1 with a
specified part of string2. The specified part of string1
runs from index start1 (inclusive) up to index end1
nil for start1 means the start of the
nil for end1 means the length of the
string. Likewise, the specified part of string2 runs from index
start2 up to index end2.
The strings are compared by the numeric values of their characters.
For instance, str1 is considered “smaller than” str2 if
its first differing character has a smaller numeric value. If
ignore-case is non-
nil, characters are converted to
lower-case before comparing them. Unibyte strings are converted to
multibyte for comparison (see Text Representations), so that a
unibyte string and its conversion to multibyte are always regarded as
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.
This function works like
assoc, except that key must be a
string or symbol, and comparison is done using
Symbols are converted to strings before testing.
If case-fold is non-
nil, it ignores case differences.
assoc, this function can also match elements of the alist
that are strings or symbols rather than conses. In particular, alist can
be a list of strings or symbols rather than an actual alist.
See Association Lists.
See also the function
Comparing Text, for a way to compare text in buffers. The
string-match, which matches a regular expression
against a string, can be used for a kind of string comparison; see