[ nedit-Bugs-1760116 ] Negated escape sequences misinterpreted in character class

Joerg Fischer jf505 at gmx.de
Tue Jul 31 22:37:56 CEST 2007


Tony Balinski wrote:

> Thanks for your comments: a useful summary and a decent opinion. I
> disagree slightly with you recommendation; I don't want to see something
> like "<\w+\y\w+>" matching two words separated by a newline outside of a
> (?n ) grouping. 

The only real problem with the (?n ) grouping I have is it forces the
dot[1] to match newlines, too, which isn't useful -- it's also not the
default in Perl. You have to force it with the extra s modifier.  As I
understand it the dot matches any character but newlines.

Therefore, if someone switches to, say, Perl compatible with the help
of the (?n ), he gets the dot wrong. Maybe we should also have a (?s )
grouping meaning (?n ) plus dot matches newlines.

Personally, I don't see too much benefit in the \n convention.  That
is because the convention that [^...] doesn't match \n only saves the
work to list \n, which makes things clearer.  What the escape sequences 
are concerned, they can be defined to mean whatever one likes at the
cost of surprising folks. (In vim \s is called white-spaces and seems
to be only [ \t].  Then \S is called non-white-spaces, but the class
isn't listed explicitly, so you may wonder what it really is.)

Anyway, having a (?N ) grouping as default, which excludes \n from
anything, unless it is listed verbatim, is perfectly alright -- if
there are equally sane alternatives[1].


Cheers,
Jörg

[1] Please don't let \S match newlines -- and dot only if really
    desired.


More information about the Develop mailing list