unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* minor question for lispref/searching.texi,v -r1.69
@ 2006-03-08 10:54 Giorgos Keramidas
  2006-03-08 12:19 ` Giorgos Keramidas
  0 siblings, 1 reply; 2+ messages in thread
From: Giorgos Keramidas @ 2006-03-08 10:54 UTC (permalink / raw)


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 appears.@refill
%
% +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
% +@samp{[} 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,
% +@code{[^][]]}, consists of the complemented character alternative
% +@code{[^][]}, 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
% +@samp{[}, 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
% +@samp{[} followed by a @samp{^}.  This lasts until the next special
% +@samp{]} 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: minor question for lispref/searching.texi,v -r1.69
  2006-03-08 10:54 minor question for lispref/searching.texi,v -r1.69 Giorgos Keramidas
@ 2006-03-08 12:19 ` Giorgos Keramidas
  0 siblings, 0 replies; 2+ messages in thread
From: Giorgos Keramidas @ 2006-03-08 12:19 UTC (permalink / raw)


On 2006-03-08 12:54, Giorgos Keramidas <keramida@ceid.upatras.gr> wrote:
> Revision 1.69 of lispref/searching.texi includes:
>
> % +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
> % +@samp{[} 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,
> % +@code{[^][]]}, consists of the complemented character alternative
> % +@code{[^][]}, which matches any single character that is not a square
> % +bracket, followed by a literal @samp{]}.
>
> 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?

Hum.  Nevermind.  Not enough coffee yet, I guess.  I just noticed the
character I've missed.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-08 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-08 10:54 minor question for lispref/searching.texi,v -r1.69 Giorgos Keramidas
2006-03-08 12:19 ` Giorgos Keramidas

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).