SqlListenerUtils { public static String translateSqlWildcardsToRegex(String sqlPtrn) { if (F.isEmpty(sqlPtrn)) return sqlPtrn; String toRegex = ' ' + sqlPtrn; toRegex = toRegex.replaceAll("([\\[\\]{}()*+?.\\\\\\\\^$|])", "\\\\$1"); toRegex = toRegex.replaceAll("([^\\\\\\\\])((?:\\\\\\\\\\\\\\\\)*)%", "$1$2.*"); toRegex = toRegex.replaceAll("([^\\\\\\\\])((?:\\\\\\\\\\\\\\\\)*)_", "$1$2."); toRegex = toRegex.replaceAll("([^\\\\\\\\])(\\\\\\\\(?>\\\\\\\\\\\\\\\\)*\\\\\\\\)*\\\\\\\\([_|%])", "$1$2$3"); return toRegex.substring(1); }  @Nullable static Object readObject(BinaryReaderExImpl reader, boolean binObjAllow); @Nullable static Object readObject(BinaryReaderExImpl reader, boolean binObjAllow, boolean keepBinary); @Nullable static Object readObject(byte type, BinaryReaderExImpl reader, boolean binObjAllow,
        boolean keepBinary); static void writeObject(BinaryWriterExImpl writer, @Nullable Object obj, boolean binObjAllow); static boolean isPlainType(Class<?> cls); static String translateSqlWildcardsToRegex(String sqlPtrn);  }
@Test public void translateAllPrintableCharacters() { String str = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; String translated = SqlListenerUtils.translateSqlWildcardsToRegex(str); str.matches(translated); }