[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Semantics of empty matches in string.gmatch and string.gsub
- From: Coda Highland <chighland@...>
- Date: Tue, 30 Apr 2013 00:06:34 -0700
On Mon, Apr 29, 2013 at 11:55 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> With this distinction available, the question reduces to:
> should "a*" return [2,3) or [2,3]?
>
> Adam made a good point here: a greedy quantifier should make
> the longest possible match. One could generalize that as follows:
>
> 1. A zero-length match always includes its endpoint.
> 2. A greedy quantifier always includes its endpoint.
> 3. A non-greedy quantifier does not include its endpoint, except when
> the match is empty.
>
Thanks. This was actually my intent in bringing it up, but you've done
an excellent job of formalizing it.
/s/ Adam