[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A bug in string.gmatch and string.gsub?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 29 Apr 2013 21:10:53 +0200
>> > 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?
>>
>> It has the advantage of making `split` trivial instead of requiring the
>> sort of thing that takes the Lua Wiki 300 lines to explain.
>
> True, but that does not make it more intuitive; it makes it more useful
> in one particular case. Are there other scenarios where it is more (or
> less) useful?
Besides `sed`, there's also Python:
>>> import re
>>> re.subn(re.compile("a*"),"ITEM",";a;")
('ITEM;ITEM;ITEM', 3)
Many Lua users come from a background in which they know sed and Python.
That tends to influence what things they find intuitive.