Pattern () { String customFilter = getCustomFilter(); if (myCustomPattern == null && customFilter != null) { final StringBuilder buf = new StringBuilder(customFilter.length()); for (int i = 0; i < customFilter.length(); i++) { final char c = customFilter.charAt(i); if (Character.isLetterOrDigit(c)) { buf.append(Character.toUpperCase(c)); } else { buf.append("\\").append(c); } } myCustomPattern = Pattern.compile(".*" + buf + ".*", Pattern.DOTALL); } return myCustomPattern; }