private static String cleanStringForWordBoundaryMatching(final String str) {
        if (CAMEL_CASE_PATTERN.matcher(str).matches()) {
            LOGGER.trace("str [{}] is (C|c)amelCase", str);

            // replace stuff like SQLScript with "SQL Script"
            String separatedStr = CAMEL_CASE_ABBREVIATIONS_PATTERN
                    .matcher(str)
                    .replaceAll("$1 $2");

            LOGGER.trace("separatedStr: [{}]", separatedStr);

            // Now split on camel case word boundaries (or spaces added above)
            separatedStr = CAMEL_CASE_SPLIT_PATTERN
                    .matcher(separatedStr)
                    .replaceAll(" ");

            LOGGER.trace("separatedStr: [{}]", separatedStr);

            return separatedStr;
        } else {
            return str;
        }
    }
For a given user input this method will return a function that can evaluate a string to see how
good the match is. The quality of the match is determined by the length of the matched region
(shorter == better) and its distance from the start of the string (closer == better).
stroom-query/stroom-query-common/src/main/java/stroom/query/common/v2/StringPredicateFactory.java