aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2006-03-09 02:03:20 +0000
committerLuc Teirlinck2006-03-09 02:03:20 +0000
commita955f5752eafd3eb85bf7511dfcb97159eeaedf5 (patch)
tree5be2e9193161a06e3dc6839c4cc56aabc776c56f
parentfc1d338658bc9d0e877c68693ee5ad05a5865b60 (diff)
downloademacs-a955f5752eafd3eb85bf7511dfcb97159eeaedf5.tar.gz
emacs-a955f5752eafd3eb85bf7511dfcb97159eeaedf5.zip
(Regexps): More accurately describe which characters are special in
which situations. Recommend _not_ to quote `]' or `-' when they are not special.
-rw-r--r--man/search.texi20
1 files changed, 15 insertions, 5 deletions
diff --git a/man/search.texi b/man/search.texi
index 443de66cbf5..4afcba837e9 100644
--- a/man/search.texi
+++ b/man/search.texi
@@ -498,11 +498,13 @@ elisp, The Emacs Lisp Reference Manual}.
498special constructs and the rest are @dfn{ordinary}. An ordinary 498special constructs and the rest are @dfn{ordinary}. An ordinary
499character is a simple regular expression which matches that same 499character is a simple regular expression which matches that same
500character and nothing else. The special characters are @samp{$}, 500character and nothing else. The special characters are @samp{$},
501@samp{^}, @samp{.}, @samp{*}, @samp{+}, @samp{?}, @samp{[}, @samp{]} and 501@samp{^}, @samp{.}, @samp{*}, @samp{+}, @samp{?}, @samp{[}, and
502@samp{\}. Any other character appearing in a regular expression is 502@samp{\}. The character @samp{]} is special if it ends a character
503ordinary, unless a @samp{\} precedes it. (When you use regular 503alternative (see later). The character @samp{-} is special inside a
504expressions in a Lisp program, each @samp{\} must be doubled, see the 504character alternative. Any other character appearing in a regular
505example near the end of this section.) 505expression is ordinary, unless a @samp{\} precedes it. (When you use
506regular expressions in a Lisp program, each @samp{\} must be doubled,
507see the example near the end of this section.)
506 508
507 For example, @samp{f} is not a special character, so it is ordinary, and 509 For example, @samp{f} is not a special character, so it is ordinary, and
508therefore @samp{f} is a regular expression that matches the string 510therefore @samp{f} is a regular expression that matches the string
@@ -682,6 +684,14 @@ no preceding expression on which the @samp{*} can act. It is poor practice
682to depend on this behavior; it is better to quote the special character anyway, 684to depend on this behavior; it is better to quote the special character anyway,
683regardless of where it appears. 685regardless of where it appears.
684 686
687As a @samp{\} is not special inside a character alternative, it can
688never remove the special meaning of @samp{-} or @samp{]}. So you
689should not quote these characters when they have no special meaning
690either. This would not clarify anything, since backslashes can
691legitimately precede these characters where they @emph{have} special
692meaning, as in @code{[^\]} (@code{"[^\\]"} for Lisp string syntax),
693which matches any single character except a backslash.
694
685@node Regexp Backslash 695@node Regexp Backslash
686@section Backslash in Regular Expressions 696@section Backslash in Regular Expressions
687 697