docs: public static String escapePattern(String source) {
  
          if (source == null) {
              return null;
          }
          StringBuffer result = new StringBuffer(source.length() * 2);
          for (int i = 0; i < source.length(); ++i) {
              char ch = source.charAt(i);
              switch (ch) {
                  case '\\':
                      result.append("\\\\");
                      break;
                  case '/':
                      result.append("\\/");
                      break;
                  case '$':
                      result.append("\\$");
                      break;
                  case '^':
                      result.append("\\^");
                      break;
                  case '.':
                      result.append("\\.");
                      break;
                  case '*':
                      result.append("\\*");
                      break;
                  case '+':
                      result.append("\\+");
                      break;
                  case '|':
                      result.append("\\|");
                      break;
                  case '?':
                      result.append("\\?");
                      break;
                  case '{':
                      result.append("\\{");
                      break;
                  case '}':
                      result.append("\\}");
                      break;
                  case '[':
                      result.append("\\[");
                      break;
                  case ']':
                      result.append("\\]");
                      break;
                  case '(':
                      result.append("\\(");
                      break;
                  case ')':
                      result.append("\\)");
                      break;
                  default:
                      result.append(ch);
              }
          }
          return new String(result);
      }