static public String generalizeWildcard(String s) {
        if (s==null)
            return "*";
        int ix=s.length()-1;
        if(ix<=1)
            return "*";
        while(ix>0 && s.charAt(ix)=='*')
            ix--; // skip any * fields starting from the end
        return s.substring(0, ix)+"*";
    }