private static int checkCapture ( MatchState ms, int ll ) {
        int l = ll - '1'; // convert chars 1-9 to actual ints 1-9
        BaseLib.luaAssert(l < 0 || l >= ms.level || ms.capture[l].len == CAP_UNFINISHED,
        "invalid capture index");
        return l;
    }
Only works with non-negative numbers
main/src/main/java/cgeo/geocaching/wherigo/kahlua/stdlib/StringLib.java