private static void handleEscapeChar(StringBuilder sb, char[] arr, int nextCharIndex) {
        if (nextCharIndex >= arr.length) {
            sb.append(ESCAPE_CHAR);
        } else {
            char next = arr[nextCharIndex];
            switch (next) {
            case COMMA_CHAR:
                // escape not needed
                break;
            case 'Q':
            case 'E':
                // extra escape needed
                sb.append(ESCAPE_CHAR).append(ESCAPE_CHAR);
                break;
            default:
                sb.append(ESCAPE_CHAR);
            }
            sb.append(next);
        }
    }
Converts a standard POSIX Shell globbing pattern into a regular expression pattern. The result can be used with the standard
{@link java.util.regex} API to recognize strings which match the glob pattern.

<p>
See also, the POSIX Shell language: http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_01
</p>
Adapted from https://stackoverflow.com/a/17369948 with the difference that a single * is not interpreted as including slashes ("/").

@param pattern A glob pattern.
@return A regex pattern to recognize the given glob pattern.
jsonschema-maven-plugin/src/main/java/com/github/victools/jsonschema/plugin/maven/GlobHandler.java