emacs-devel
[Top][All Lists]
Advanced

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

Re: Should not * be greedy in a regexp?


From: Lennart Borgman (gmail)
Subject: Re: Should not * be greedy in a regexp?
Date: Sat, 03 Nov 2007 20:12:35 +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

Andreas Schwab wrote:
Andreas Schwab <address@hidden> writes:

"Lennart Borgman (gmail)" <address@hidden> writes:

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.
The regexp matches the empty string.

... at the start of the string, I wanted to add.

Ah, thanks.




reply via email to

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