[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Documentation for string.find, indexes
- From: David Jones <drj@...>
- Date: Sun, 3 Oct 2004 19:27:31 +0100
It would be ever so slightly useful if the documentation for
string.find asserted that the returned indexes were positive.
This would allow code like this (that gets the string that follows a
match):
s, e = string.find(str, 'foo')
follows = string.sub(str, e+1)
to be written safe in the knowledge that << e+1 >> would never be 0.
This is just a documentation change, because of course the current
implementation does only return positive indexes.
Similarly for the indexes returned by << () >> captures.
By the way, the 4th argument to string.find is very unpleasant. It
would be better to provide a string.ffind (for "fixed find") that
performs the plain find substring operation. I'm not partial to the
exact name (I just borrowed it from fgrep). I note that string.gfind
does not have an analogous interface.
David Jones