[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A bug in string.gmatch and string.gsub?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 29 Apr 2013 13:11:26 -0300
> 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?