private static String splitWords(String str) {
        if (str.isEmpty()) {
            return "";
        }

        final StringBuilder result = new StringBuilder();
        int tokenStart = 0;
        int currentType = Character.getType(str.charAt(tokenStart));

        for (int pos = tokenStart + 1; pos < str.length(); pos++) {
            final char c = str.charAt(pos);
            final int type = Character.getType(c);
            if (type == currentType) {
                continue;
            }
            if (type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
                final int newTokenStart = pos - 1;
                if (newTokenStart != tokenStart) {
                    addLowerCaseStringToBuilder(result, str, tokenStart, newTokenStart - tokenStart);
                    result.append(' ');
                    tokenStart = newTokenStart;
                }
            } else {
                // Skip character groupings that are delimiters. We just want letters and numbers.
                if (Character.isLetterOrDigit(str.charAt(pos - 1))) {
                    addLowerCaseStringToBuilder(result, str, tokenStart, pos - tokenStart);
                    result.append(' ');
                }
                tokenStart = pos;
            }
            currentType = type;
        }

        if (Character.isLetterOrDigit(str.charAt(tokenStart))) {
            // Add the last segment if it's a letter or number.
            addLowerCaseStringToBuilder(result, str, tokenStart, str.length() - tokenStart);
        } else {
            // Since the last segment is ignored, remove the trailing space.
            result.setLength(result.length() - 1);
        }

        return result.toString();
    }
Returns the first term that the input text matched.
@param text the String within which to search for matches
@return the first match found
smithy-linters/src/main/java/software/amazon/smithy/linters/WordBoundaryMatcher.java