Skip to content

Instantly share code, notes, and snippets.

@error454
Last active December 14, 2015 12:29
Show Gist options
  • Save error454/5086712 to your computer and use it in GitHub Desktop.
Save error454/5086712 to your computer and use it in GitHub Desktop.
Find the last index of the specified pattern in a string. For ShiVa 3D game engine.
--------------------------------------------------------------------------------
function YourAI.findLastIndexOf ( sString, sPattern, nIndex )
--------------------------------------------------------------------------------
local firstIndex = string.findFirst ( sString, sPattern, nIndex )
if(firstIndex == -1)
then
return nIndex - 1
else
return this.findLastIndexOf ( sString, sPattern, firstIndex + 1 )
end
--------------------------------------------------------------------------------
end
--------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment