我希望能够lastIndexOf
在Lua(Luvit)项目中为字符串使用方法.不幸的是,没有内置的这种方法,我现在有点卡住了.
在Javascript中它看起来像:
'my.string.here.'.lastIndexOf('.') // returns 14
lhf.. 10
function findLast(haystack, needle) local i=haystack:match(".*"..needle.."()") if i==nil then return nil else return i-1 end end s='my.string.here.' print(findLast(s,"%.")) print(findLast(s,"e"))
请注意,要找到.
你需要逃避它.