private void generatePattern(String filter) {
        expr = new String(filter);

        int index = filter.indexOf("\\");
        String toReplace = "\\\\";

        while (index != -1) {
            filter = filter.substring(0, index) + toReplace +
                filter.substring(index + 1);
            index = filter.indexOf("\\", index + 2);
        }

        index = filter.indexOf(".");
        toReplace = "\\x2E";

        while (index != -1) {
            filter = filter.substring(0, index) + toReplace +
                filter.substring(index + 1);
            index = filter.indexOf(".", index + 1);
        }

        index = filter.indexOf("*");
        toReplace = ".*";

        while (index != -1) {
            filter = filter.substring(0, index) + toReplace +
                filter.substring(index + 1);
            index = filter.indexOf("*", index + 2);
        }

        int fpar = filter.indexOf("{");
        int lpar = filter.indexOf("}");

        while ((fpar + lpar) != -2) {
            index = filter.indexOf(",");
            toReplace = "|";

            while (index != -1) {
                if ((index > fpar) && (index < lpar)) {
                    filter = filter.substring(0, index) + toReplace +
                        filter.substring(index + 1);
                }

                index = filter.indexOf(",", index + 1);
            }

            filter = filter.substring(0, fpar) + "(" +
                filter.substring(fpar + 1, lpar) + ")" +
                filter.substring(lpar + 1);
            fpar = filter.indexOf("{");
            lpar = filter.indexOf("}");
        }

        index = filter.indexOf("?");
        toReplace = ".";

        while (index != -1) {
            filter = filter.substring(0, index) + toReplace +
                filter.substring(index + 1);
            index = filter.indexOf("?", index + 1);
        }

        pattern = Pattern.compile(filter);
    }