result = coreRegex.toString();
    private String getVariableRegex(Variable variable) {        String result = null;        if (variable.isFixed()) {            result = Pattern.quote(variable.getDefaultValue());        } else {            // Expressions to create character classes            final String ALL = ".";            final String ALPHA = "a-zA-Z";            final String DIGIT = "0-9";            final String ALPHA_DIGIT = ALPHA + DIGIT;            final String HEXA = DIGIT + "ABCDEF";            final String URI_UNRESERVED = ALPHA_DIGIT + "\\-\\.\\_\\~";            final String URI_GEN_DELIMS = "\\:\\/\\?\\#\\[\\]\\@";            final String URI_SUB_DELIMS = "\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=";            final String URI_RESERVED = URI_GEN_DELIMS + URI_SUB_DELIMS;            final String URI_ALL = URI_RESERVED + URI_UNRESERVED;            final String WORD = "\\w";            // Expressions to create non-capturing groups            final String PCT_ENCODED = "\\%[" + HEXA + "][" + HEXA + "]";            final String PCHAR = "[" + URI_UNRESERVED + "]|(?:" + PCT_ENCODED                    + ")|[" + URI_SUB_DELIMS + "]|\\:|\\@";            final String QUERY = PCHAR + "|\\/|\\?";            final String FRAGMENT = QUERY;            StringBuilder coreRegex = new StringBuilder();            switch (variable.getType()) {            case Variable.TYPE_ALL:                appendClass(coreRegex, ALL, variable.isRequired());                break;            case Variable.TYPE_ALPHA:                appendClass(coreRegex, ALPHA, variable.isRequired());                break;            case Variable.TYPE_DIGIT:                appendClass(coreRegex, DIGIT, variable.isRequired());                break;            case Variable.TYPE_ALPHA_DIGIT:                appendClass(coreRegex, ALPHA_DIGIT, variable.isRequired());                break;            case Variable.TYPE_URI_ALL:                appendClass(coreRegex, URI_ALL, variable.isRequired());                break;            case Variable.TYPE_URI_UNRESERVED:                appendClass(coreRegex, URI_UNRESERVED, variable.isRequired());                break;            case Variable.TYPE_WORD:                appendClass(coreRegex, WORD, variable.isRequired());                break;            case Variable.TYPE_URI_FRAGMENT:                appendGroup(coreRegex, FRAGMENT, variable.isRequired());                break;            case Variable.TYPE_URI_QUERY:                appendGroup(coreRegex, QUERY, variable.isRequired());                break;            case Variable.TYPE_URI_SEGMENT:                appendGroup(coreRegex, PCHAR, variable.isRequired());                break;            }        }        return result;    }