private static StringPointer minExpand ( MatchState ms, StringPointer ss, StringPointer p, StringPointer ep ) {
        StringPointer sp = ep.getClone();
        StringPointer s = ss.getClone();

        sp.postIncrString ( 1 );
        while (true) {
            StringPointer res = match ( ms, s, sp );
            if ( res != null ) {
                return res;
            } else if ( s.getIndex () < ms.endIndex && singleMatch ( s.getChar (), p, ep ) ) {
                s.postIncrString ( 1 );  // try with one more repetition
            } else {
                return null;
            }
        }
    }
Only works with non-negative numbers
main/src/main/java/cgeo/geocaching/wherigo/kahlua/stdlib/StringLib.java