code: public static String quote(final String string) {
          int last = 0;
          final StringBuilder sb = new StringBuilder();
          for (int i = 0; i < string.length(); i++) {
              if (needsQuoting(string.charAt(i))) {
                  sb.append(string, last, i);
                  last = i = quote(sb, string, i);
              }
          }
          sb.append(string, last, string.length());
          return sb.toString();
      }
docs: Like {@link Pattern#quote(java.lang.String)}, but avoids unnecessary
  quotes to make result more human-readable.
  @param string
  @return the quoted pattern