Last active
December 14, 2015 12:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------------------------------------------------------------------------------- | |
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