Here you can find the source of wildcard2Regex(final String wildcard)
static final public String wildcard2Regex(final String wildcard)
//package com.java2s; //License from project: Apache License public class Main { static final public String wildcard2Regex(final String wildcard) { StringBuffer s = new StringBuffer((int) (wildcard.length() * 1.3)); String w = wildcard;/*from w w w .ja va 2 s.c o m*/ for (int i = 0, is = w.length(); i < is; i++) { char c = w.charAt(i); switch (c) { case '*': s.append(".*"); break; case '?': s.append("."); break; case '(': case ')': case '[': case ']': case '$': case '^': case '.': case '{': case '}': case '|': case '\\': s.append("\\"); s.append(c); break; default: s.append(c); break; } } return s.toString(); } }