lua-users home
lua-l archive

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


David Burgess wrote:

> I note that string.find(s,"%f[%w]) returns an endposition
> 1 less than the start.

I assume this is because the thing it's searching for is
zero characters wide.  If the start and end positions were
the same number, let's say 42, that would mean that the
frontier was the 42nd character, when really it's the space
between the 41st and 42nd characters.  Since the Lua string
functions (unlike those of Python) deal in terms of first
and last characters and not the positions respectively
before and after those characters, the only way to express
the position of a zero-length string is to return, in our
example, 42 and 41.

-- 
Aaron Brown
Oak Adaptive