[Top][All Lists]

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

Re: Should not * be greedy in a regexp?

From: Stefan Monnier
Subject: Re: Should not * be greedy in a regexp?
Date: Sat, 03 Nov 2007 21:55:29 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

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

The regexp-matching is greedy, so it matches the longest match, but the
regexp-search will return the leftmost (i.e. first) match, so mod-regx*
will match at the very first position (matching the mprty string),
whereas mod-regx+ will fail at that position so it will then succeed at
the second position where both mod-regx+ and mod-regx* would match the
same string.


reply via email to

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