lua-users home
lua-l archive

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

2017-10-11 12:06 GMT+02:00 Soni L. <>:
> On 2017-10-11 05:27 AM, Dirk Laurie wrote:
>> 2017-10-11 4:51 GMT+02:00 Soni L. <>:
>>> It's one of:
>>> - caret is wrong
>>> - frontier is wrong
>>> - manual is wrong
>> A fourth possibility: behaviour of a bare "^" is undefined.
>> Lua is replete with silentlly undefined and implementation-dependent
>> behaviour. It is impossible for manual writers to anticipate to what
>> lengths fractious but resourceful users might go.
> I'd still like for %f to match at the start of a match. Is there a good
> reason why it doesn't?

Specifying a starting position means that one is not interested in frontiers
before a certain point, not that a non-frontier should be treated as a frontier.

It is easy to get that behaviour if you want it: just code str:sub(n):match(pat)
instead of str:match(pat,n). Whereas if that behaviour were the default,
there would be no easy way of not getting it if you don't want it.