[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
minor question for lispref/searching.texi,v -r1.69
From: |
Giorgos Keramidas |
Subject: |
minor question for lispref/searching.texi,v -r1.69 |
Date: |
Wed, 8 Mar 2006 12:54:37 +0200 |
Revision 1.69 of lispref/searching.texi includes:
% ----------------------------
% revision 1.69
% date: 2006/03/07 23:28:33; author: teirllm; state: Exp; lines: +39 -8
% (Syntax of Regexps): More accurately describe
% which characters are special in which situations.
% (Regexp Special): Recommend _not_ to quote `]' or `-' when they
% are not special. Describe in detail when `[' and `]' are special.
% (Regexp Backslash): Plenty of regexps with unbalanced square
% brackets are valid, so reword that statement.
%
% Index: searching.texi
% ===================================================================
% RCS file: /home/emacs/emacs/lispref/searching.texi,v
% retrieving revision 1.68
% retrieving revision 1.69
% diff -u -r1.68 -r1.69
% --- searching.texi 6 Feb 2006 11:55:10 -0000 1.68
% +++ searching.texi 7 Mar 2006 23:28:33 -0000 1.69
% @@ -468,6 +471,34 @@
% can act. It is poor practice to depend on this behavior; quote the
% special character anyway, regardless of where it address@hidden
%
% +As a @samp{\} is not special inside a character alternative, it can
% +never remove the special meaning of @samp{-} or @samp{]}. So you
% +should not quote these characters when they have no special meaning
% +either. This would not clarify anything, since backslashes can
% +legitimately precede these characters where they @emph{have} special
% +meaning, as in @code{[^\]} (@code{"[^\\]"} for Lisp string syntax),
% +which matches any single character except a backslash.
% +
% +In practice, most @samp{]} that occur in regular expressions close a
% +character alternative and hence are special. However, occasionally a
% +regular expression may try to match a complex pattern of literal
% address@hidden and @samp{]}. In such situations, it sometimes may be
% +necessary to carefully parse the regexp from the start to determine
% +which square brackets enclose a character alternative. For example,
% address@hidden, consists of the complemented character alternative
% address@hidden, which matches any single character that is not a square
% +bracket, followed by a literal @samp{]}.
% +
% +The exact rules are that at the beginning of a regexp, @samp{[} is
% +special and @samp{]} not. This lasts until the first unquoted
% address@hidden, after which we are in a character alternative; @samp{[} is
% +no longer special (except when it starts a character class) but @samp{]}
% +is special, unless it immediately follows the special @samp{[} or that
% address@hidden followed by a @samp{^}. This lasts until the next special
% address@hidden that does not end a character class. This ends the character
% +alternative and restores the ordinary syntax of regular expressions;
% +an unquoted @samp{[} is special again and a @samp{]} not.
% +
% @node Char Classes
% @subsubsection Character Classes
% @cindex character classes in regexp
I think that the sample of the second paragraph doesn't match the text
description, or am I parsing the regexp incorrectly?
[^][]
This doesn't match ``the complemented character alternative "[^][]"'' or
``any single character that is not a squarebracket, followed by a
literal "]"''.
Shouldn't the regexp be ``[^]]]'' for this to be a correct description?
- Giorgos
- minor question for lispref/searching.texi,v -r1.69,
Giorgos Keramidas <=