emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unquoted special characters in regexps


From: Luc Teirlinck
Subject: Re: Unquoted special characters in regexps
Date: Sat, 25 Feb 2006 16:13:11 -0600 (CST)

Martin Rudalics wrote:

   `]' is _also_ special in a character alternative, like `^'.  `-' is
   special _only_ in a character alternative.

I may be overlooking something, but _which_ special meaning does `]'
have outside of character alternatives?

You are using \\] to quote `]'.  Could that possibly clear up any
confusion or does it just add confusion?  I personally believe the
latter.  Is there a situation where \\ can be used to prevent `]' from
having a special meaning?  In "[a\\]b]", the first `]' still has a
special meaning, even though there might be some optical illusion
making it look "quoted", the second `]' has no special meaning.

The only way I know of to put a "quoted" `]' in a character
alternative is to write it immediately after the `[' or "[^".

But "quoting" `]' by writing "[]]" instead of just `]', seems
contorted, even though it would be less confusing than "\\]".

I believe that a `]' should not be quoted at all if it is outside a
character alternative, where it has no special meaning, unless I am
overlooking something.  (Just tell what, in that case.)

ELISP> (string-match "[a\\]b]" "]")
nil
ELISP> (string-match "[a\\]b]" "\\b")
nil
ELISP> (string-match "[a\\]b]" "\\b]")
0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]