diff options
| author | Luc Teirlinck | 2006-03-09 02:03:20 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2006-03-09 02:03:20 +0000 |
| commit | a955f5752eafd3eb85bf7511dfcb97159eeaedf5 (patch) | |
| tree | 5be2e9193161a06e3dc6839c4cc56aabc776c56f | |
| parent | fc1d338658bc9d0e877c68693ee5ad05a5865b60 (diff) | |
| download | emacs-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.texi | 20 |
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}. | |||
| 498 | special constructs and the rest are @dfn{ordinary}. An ordinary | 498 | special constructs and the rest are @dfn{ordinary}. An ordinary |
| 499 | character is a simple regular expression which matches that same | 499 | character is a simple regular expression which matches that same |
| 500 | character and nothing else. The special characters are @samp{$}, | 500 | character 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 |
| 503 | ordinary, unless a @samp{\} precedes it. (When you use regular | 503 | alternative (see later). The character @samp{-} is special inside a |
| 504 | expressions in a Lisp program, each @samp{\} must be doubled, see the | 504 | character alternative. Any other character appearing in a regular |
| 505 | example near the end of this section.) | 505 | expression is ordinary, unless a @samp{\} precedes it. (When you use |
| 506 | regular expressions in a Lisp program, each @samp{\} must be doubled, | ||
| 507 | see 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 |
| 508 | therefore @samp{f} is a regular expression that matches the string | 510 | therefore @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 | |||
| 682 | to depend on this behavior; it is better to quote the special character anyway, | 684 | to depend on this behavior; it is better to quote the special character anyway, |
| 683 | regardless of where it appears. | 685 | regardless of where it appears. |
| 684 | 686 | ||
| 687 | As a @samp{\} is not special inside a character alternative, it can | ||
| 688 | never remove the special meaning of @samp{-} or @samp{]}. So you | ||
| 689 | should not quote these characters when they have no special meaning | ||
| 690 | either. This would not clarify anything, since backslashes can | ||
| 691 | legitimately precede these characters where they @emph{have} special | ||
| 692 | meaning, as in @code{[^\]} (@code{"[^\\]"} for Lisp string syntax), | ||
| 693 | which 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 | ||