|
Rici Lake wrote:
On 25-Jan-06, at 2:17 PM, Brian Weed wrote:Is there a library function for a reverse findSadly, no., or do I have to do it manually as in: -- untested i = 0 do i = i - 1 p = string.find(s, ".", i, true) while (p == nil and i ~= -string.len(s))(I'm searching for the file extension, and there may be other dots in the filename)A better way: local _, _, extension = string.find(s, ".*%.(.*)")
This works too: local _, _, extension = string.find(s, "([^.]*)$")Or perhaps string.find(s, "%.([^.]*)$") if you want to be sure that there is a dot in the input string.
-Mark