Here you can find the source of wildcardToRegex(final String input)
private static String wildcardToRegex(final String input)
//package com.java2s; //License from project: Open Source License public class Main { private static String wildcardToRegex(final String input) { StringBuilder sb = new StringBuilder(input.length() + 10); sb.append('^'); for (int i = 0; i < input.length(); ++i) { char c = input.charAt(i); if (c == '*') { sb.append(".*"); } else if (c == '?') { sb.append('.'); } else if ("\\.[]{}()+-^$|".indexOf(c) >= 0) { sb.append('\\'); sb.append(c);/* w w w .j a v a 2 s . c o m*/ } else { sb.append(c); } } sb.append('$'); return sb.toString(); } }