[Top][All Lists]

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

Re: Unquoted special characters in regexps

From: martin rudalics
Subject: Re: Unquoted special characters in regexps
Date: Thu, 02 Mar 2006 19:40:08 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>     First of all, there are (surprisingly) many occurrences of "\\]" in
>     the Emacs source, where the `]' _is_ special and closes a character
>     alternative that contains a slash.
> That is a good point.  We don't want people to get confused about that.

There are very few expressions where `\\' does have to precede a right
bracket, `[^\\]', `[]\\]', and `[^]\\]' come to mind.  I any other case
people may avoid confusion by moving the backslash in front of another

In current Emacs code there are some 100 occurrencs where programmers
were able to convey the intention that they indeed wanted to match a
right bracket by writing `\\]'.  Simultaneously, programmers were able
to express that they did _not_ want a character alternative to end here.
Your change will make it difficult if not impossible to express such

And, your change is motivated by the pessimistic assumption that people
frequently submit code with buggy regexps.  Even if that were the case
your change would hardly help.  Consider the following expression from

         "\\(\[[0-9]+\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \

Experience tells me that this should be probably written as

         "\\(\\[[0-9]+\\] \\)*\\([a-zA-Z0-9.$_]+\\)\\.[a-zA-Z0-9$_<>(),]+ \

but I'm not quite sure since `gud.el' is one of the few Emacs files that
do not consistently use `\\]' to match a right bracket.

reply via email to

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