lua-users home
lua-l archive

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


On Mon, Apr 29, 2013 at 9:11 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> I agree that there is a way to explain the current behaviour of "a*"
>> logically, BUT:
>>
>>   (a) That way is based on a rule not stated in the documentation,
>>   (b) which is not the only possible rule consistent with it.
>>   (c) Another rule can be proposed,
>>   (d) which is consistent with the way `sed` behaves,
>>   (e) appears to be more intuitive,
>>   (f) and can be implemented quite efficiently.
>
> I may be wrong, but it seems that the two rules can be stated like that:
>
> 1) Do not match two empty strings in the same position. (current Lua rule)
>
> 2) Do not match an empty string in the same position of another match
> (not necessarily empty). (sed rule)
>
> Is rule 2 really more intuitive in general or it just happen to do what
> you want in this particular case?
>
> -- Roberto
>

I find rule 2 more intuitive, myself; it makes greedy quantifiers feel
more greedy, which is good.

/s/ Adam