public static String getSubstring(String value, int startIndex, int stopIndex, boolean reverse) {
        if (startIndex >= stopIndex || value.length() < stopIndex) {
            return null;
        }

        for (int i = 0; i < value.length(); i++) {
            if (!(value.charAt(i) <= 127)) {
                return null;
            }
        }

        if (!reverse) {
            return value.substring(startIndex, stopIndex);
        } else {
            int revStart = value.length() - stopIndex;
            int revStop = value.length() - startIndex;
            return value.substring(revStart, revStop);
        }
    }
Get the substring of {@code value} using the same logic as the substring function.

@param value Value to get the substring of.
@param startIndex Start index.
@param stopIndex Stop index.
@param reverse True if the slice is from the end.
@return the substring value or null.
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/syntax/expressions/functions/Substring.java