emacs-devel
[Top][All Lists]
Advanced

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

Should not * be greedy in a regexp?


From: Lennart Borgman (gmail)
Subject: Should not * be greedy in a regexp?
Date: Sat, 03 Nov 2007 18:58:03 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

Starting from

   emacs -Q

Put this in the *scratch* buffer and eval it:

(let* ((mod-regx+ "\\(\\(?:[CSM]-\\)+\\)")
       (mod-regx* "\\(\\(?:[CSM]-\\)*\\)")
       (str "<C-S-tab>")
       (m+ (when (string-match mod-regx+ str)
             (match-string 0 str)))
       (m* (when (string-match mod-regx* str)
             (match-string 0 str))))
  (lwarn 't :warning "m+=%s, m*=%s" m+ m*))

I get

  Warning (t): m+=C-S-, m*=

Should not both this regexp give the same result here? It looks to me like * is treated as *? - ie non-greedy.


In GNU Emacs 22.1.50.1 (i386-mingw-nt5.1.2600)
 of 2007-07-04
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/g/include'





reply via email to

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