a newline, it matches the whole string. Since it @emph{can} match
starting at the first @samp{a}, it does.
+@cindex set of alternative characters, in regular expressions
+@cindex character set, in regular expressions
@item @kbd{[ @dots{} ]}
-is a @dfn{a set of alternative characters}, beginning with @samp{[}
-and terminated by @samp{]}.
+is a @dfn{set of alternative characters}, or a @dfn{character set},
+beginning with @samp{[} and terminated by @samp{]}.
In the simplest case, the characters between the two brackets are what
this set can match. Thus, @samp{[ad]} matches either one @samp{a} or
period. As another example, @samp{[α-ωί]} matches all lower-case
Greek letters.
+@cindex character classes, in regular expressions
You can also include certain special @dfn{character classes} in a
character set. A @samp{[:} and balancing @samp{:]} enclose a
-character class inside a character alternative. For instance,
+character class inside a set of alternative characters. For instance,
@samp{[[:alnum:]]} matches any letter or digit. @xref{Char Classes,,,
elisp, The Emacs Lisp Reference Manual}, for a list of character
classes.
to depend on this behavior; it is better to quote the special character anyway,
regardless of where it appears.
-As a @samp{\} is not special inside a character alternative, it can
+As a @samp{\} is not special inside a set of alternative characters, it can
never remove the special meaning of @samp{-}, @samp{^} or @samp{]}.
-So you should not quote these characters when they have no special
-meaning either. This would not clarify anything, since backslashes
+You should not quote these characters when they have no special
+meaning. This would not clarify anything, since backslashes
can legitimately precede these characters where they @emph{have}
special meaning, as in @samp{[^\]} (@code{"[^\\]"} for Lisp string
syntax), which matches any single character except a backslash.
As a @samp{\} is not special inside a character alternative, it can
never remove the special meaning of @samp{-}, @samp{^} or @samp{]}.
-So you should not quote these characters when they have no special
-meaning either. This would not clarify anything, since backslashes
+You should not quote these characters when they have no special
+meaning. This would not clarify anything, since backslashes
can legitimately precede these characters where they @emph{have}
special meaning, as in @samp{[^\]} (@code{"[^\\]"} for Lisp string
syntax), which matches any single character except a backslash.
@cindex category, regexp search for
@item \c@var{code}
matches any character whose category is @var{code}. Here @var{code}
-is a character that represents a category: thus, @samp{code} for
-Chinese characters or @samp{g} for Greek characters in the standard
-category table. You can see the list of all the currently defined
-categories with @kbd{M-x describe-categories @key{RET}}. You can also
-define your own categories in addition to the standard ones using the
-@code{define-category} function (@pxref{Categories}).
+is a character that represents a category: for example, in the standard
+category table, @samp{c} stands for Chinese characters and @samp{g}
+stands for Greek characters. You can see the list of all the
+currently defined categories with @w{@kbd{M-x describe-categories
+@key{RET}}}. You can also define your own categories in addition to
+the standard ones using the @code{define-category} function
+(@pxref{Categories}).
@item \C@var{code}
matches any character whose category is not @var{code}.