private static String parseWordPattern(String pattern) {
        boolean previousSpace = false;
        StringBuilder result = new StringBuilder(pattern.length() - 2);
        for (int i = 0; i < pattern.length(); i++) {
            char c = pattern.charAt(i);
            result.append(Character.toLowerCase(c));
            if (c == ' ') {
                // Ensure that extraneous spaces aren't found at the beginning, end, or between words.
                if (i == 0 || i == pattern.length() - 1 || previousSpace) {
                    throw new IllegalArgumentException("Invalid spaces in word boundary search: " + pattern);
                } else {
                    previousSpace = true;
                }
            } else if (!Character.isLetterOrDigit(c)) {
                throw new IllegalArgumentException(
                        "Invalid non-alphanumeric characters in word boundary search:" + pattern);
            } else {
                previousSpace = false;
            }
        }

        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