code: protected static String toWildcardExpression( String likeExpression ) {
          if (likeExpression.isEmpty()) {
              return likeExpression;
          }
          final int sz = likeExpression.length();
          final StringBuilder buf = new StringBuilder(sz);
          int pos = -1;
          while (++pos < sz) {
              final char c = likeExpression.charAt(pos);
              char out;
              switch (c) {
                  case '%':
                  case '*':
                      buf.append('*');
                      continue;
                  case '_':
                  case '?':
                      buf.append('?');
                      continue;
                  case '\\':
                      if (++pos < sz) {
                          out = likeExpression.charAt(pos);
                          break;
                      }
                      // weird case with a trailing backslash, treat as "escaped nothing" i.e. skip it
                      continue;
                  default:
                      out = c;
              }
              if (LUCENE_SPECIAL_CHARACTERS.indexOf(out) >= 0) {
                  buf.append('\\');
              }
              buf.append(c);
          }
          return buf.toString();
      }
docs: Convert the JCR like expression to a Lucene wildcard expression. The JCR like expression uses '%' to match 0 or more
  characters, '_' to match any single character, '\x' to match the 'x' character, and all other characters to match
  themselves. Since ModeShape v5.5, this method additionally escapes Lucene special characters, with the exception,
  for backwards compatibility, of the '*' and '?' wildcard characters themselves, which are supported alternatives
  despite not being officially part of the JCR specification.
  
  @param likeExpression the like expression; may not be null
  @return the expression that can be used with a WildcardQuery; never null