emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: M-x occur and `[^a-z]$'


From: Luc Teirlinck
Subject: Re: M-x occur and `[^a-z]$'
Date: Tue, 27 Jun 2006 13:04:01 -0500 (CDT)

Mark Plaskin wrote:

   Put this in the *scatch* buffer:
   a1
   b
   c1
   d
   e1
   f
   g1
   h
   i1
   j
   k1
   l
   m1
   n

   Go to the top of the buffer and type M-x occur RET [^a-z]$ RET

   You'll get this:

   8 matches for "[^a-z]$" in buffer: *scratch*
         1:a1
         3:c1
         5:e1
         7:g1
         9:i1
        11:k1
        13:m1
        14:n

   But line 14 doesn't match the regexp, does it?

I assume that you have a newline after the n, followed by a completely
empty line.  Then line 14 _does_ match.  You have a newline, which
matches [^a-z], followed by an end of line.  Elisp regexps behave
differently in this respect from grep regexps.

>From `(elisp)Regexp Special':

     A complemented character alternative can match a newline, unless
     newline is mentioned as one of the characters not to match.  This
     is in contrast to the handling of regexps in programs such as
     `grep'.

Sincerely,

Luc.






reply via email to

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