public static Value substring(final boolean indexStartsWithZero, @NonNull final ValueList valueList) {
        valueList.assertCheckCount(1, 3, false);
        final String value = valueList.getAsString(0, "");
        final int valueLength = value.length();

        //start value
        int start = 0;
        if (valueList.size() > 1) {
            final Value startValue = valueList.get(1);
            final int startValueInt = (int) startValue.getAsLong();
            if (indexStartsWithZero) {
                valueList.assertCheckType(1, v -> v.isLongBetween(-valueLength, valueLength),
                    "start must be between -" + valueLength + " and " + valueLength, false);
                start = startValueInt < 0 ? valueLength + startValueInt : startValueInt;
            } else {
                valueList.assertCheckType(1, v -> v.isLongBetween(-valueLength, valueLength + 1) && !v.isNumericZero(),
                    "start must be between -" + valueLength + " and " + (valueLength + 1) + " and not zero", false);
                start = startValueInt < 0 ? valueLength + startValueInt : startValueInt - 1;
            }
        }

        //length
        final int maxLength = valueLength - start;
        int length = maxLength;
        if (valueList.size() > 2) {
            valueList.assertCheckType(2, v -> v.isLongBetween(0, maxLength), "length must be between 0 and " + maxLength, false);
            length = (int) valueList.get(2).getAsLong();
        }

        return Value.of(value.substring(start, start + length));
    }
Holds implementations for functions in Formula
main/src/main/java/cgeo/geocaching/utils/formulas/FormulaUtils.java