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: Andreas Schwab
Subject: Re: Should not * be greedy in a regexp?
Date: Sat, 03 Nov 2007 19:48:29 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux)

"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.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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