TextUtils { public static Pattern buildLikePattern(String pattern) { return buildLikePattern(pattern, false); } private  TextUtils(); static String getEolStr(); static String stringToHTMLString(String string); static int[] getLocation(int bl, int bc, int el, int ec,
                String[] lines); static Pattern buildLikePattern(String pattern); static Pattern buildLikePattern(String pattern, boolean caseInsensitive); static Pattern buildSimilarToPattern(String pattern);  }
@Test public void testLikePattern() { Pattern p = TextUtils.buildLikePattern("str%a_8"); match(p, "straaa8"); match(p, "straa8"); match(p, "strah8"); match(p, "strazertyam8"); notMatch(p, "stra8"); notMatch(p, "straa"); notMatch(p, "strazertya118"); notMatch(p, "1straaa8"); p = TextUtils.buildLikePattern("%str"); match(p, "str"); match(p, "astr"); match(p, "strstr"); match(p, "azerty34str"); notMatch(p, "tr"); notMatch(p, "str12"); notMatch(p, "azertstrf"); notMatch(p, "st"); p = TextUtils.buildLikePattern("_str%"); match(p, "sstr"); match(p, "astr"); match(p, "7strstr"); match(p, "astrazert5y"); notMatch(p, "str"); notMatch(p, "str12stuff"); notMatch(p, "sst"); notMatch(p, "zzstr"); p = TextUtils.buildLikePattern("__tr%"); match(p, "sstr"); match(p, "astr23"); match(p, "7strstr"); match(p, "trtrz"); notMatch(p, "str"); notMatch(p, "str12stuff"); notMatch(p, "sst"); notMatch(p, "zzztr12"); p = TextUtils.buildLikePattern("_str%%"); match(p, "sstr"); match(p, "astr"); match(p, "7strstr"); match(p, "astrazert5y"); notMatch(p, "str"); notMatch(p, "str12stuff"); notMatch(p, "sst"); notMatch(p, "zzstr"); p = TextUtils.buildLikePattern("__"); match(p, "gg"); match(p, "a1"); notMatch(p, "str"); notMatch(p, "s"); notMatch(p, "1234g"); p = TextUtils.buildLikePattern("%%"); match(p, "gg"); match(p, "a1"); match(p, "str"); match(p, "s"); match(p, "1234g"); p = TextUtils.buildLikePattern("str\\%a_8"); match(p, "str%aa8"); match(p, "str%ab8"); notMatch(p, "stra8"); notMatch(p, "straa8"); notMatch(p, "strazertyaj8"); notMatch(p, "1straaa8"); p = TextUtils.buildLikePattern("str\\%a\\_8"); match(p, "str%a_8"); notMatch(p, "str%ab8"); notMatch(p, "stra8"); notMatch(p, "straa8"); notMatch(p, "strazertyaj8"); notMatch(p, "1straaa8"); p = TextUtils.buildLikePattern("\\\\"); match(p, "\\"); notMatch(p, "\\\\"); notMatch(p, "s\\"); notMatch(p, "\\sse"); p = TextUtils.buildLikePattern("ab\\_"); match(p, "ab_"); notMatch(p, "aba"); notMatch(p, "ab_b"); }