title: String replaceAll() method replace except string
body: <p>I am trying to use the <code>replaceAll()</code> method to replace a everything on a string except a a string sequence but I don't make it work, I have the following code:</p>
  
  <p>Basically: </p>
  
  <pre><code>String message = "§eTeste"
  
  String color = message.replaceAll(?, ""); // The problem
  
  System.out.println(color);
  </code></pre>
  
  <p>Output should be "§e"</p>
  
  <p>Code:</p>
  
  <pre><code>        String[] args = message.split(" ");
          StringBuilder sb = new StringBuilder();
  
          for (int i = 0; i &lt; args.length; i++) {
              String teste = args[i].replaceAll("§[0-9A-Fa-fK-Rk-r]", "");
  
              if (i == (args.length-1)) {
                  if (teste.matches("http://" + "(.*)") || teste.matches("https://" + "(.*)")) {
  
                      String cor = "";
                      if (!args[i].matches("(.*)" + "§[0-9A-Fa-fK-Rk-r]" + "(.*)") &amp;&amp; (sb.toString() !=null) &amp;&amp; !sb.toString().isEmpty()) {
                          cor = sb.toString().replaceAll("[^(§[0-9A-Fa-fK-Rk-r])]", "");
                      }
  
                      if ((sb.toString() !=null) &amp;&amp; !sb.toString().isEmpty()) {
                          JSONObject objeto = new JSONObject();
  
                          objeto.put("text", sb.toString());
                          jmessage.add(objeto);
                      }
  
                      JSONObject objeto = new JSONObject();
                      JSONObject extra = new JSONObject();
  
                      extra.put("action", "open_url");
                      extra.put("value", teste);
  
                      objeto.put("text", cor + args[i]);
                      objeto.put("clickEvent", extra);
  
                      jmessage.add(objeto);
                  }
                  else {
                      JSONObject objeto = new JSONObject();
  
                      sb.append(args[i]);
  
                      objeto.put("text", sb.toString());
                      jmessage.add(objeto);
                  }
              }
              else {
                  if (teste.matches("http://" + "(.*)") || teste.matches("https://" + "(.*)")) {
  
                      String cor = "";
                      if (args[i].matches("(.*)" + "§[0-9A-Fa-fK-Rk-r]" + "(.*)")) {
                          cor = args[i].replaceAll("[^(§[0-9A-Fa-fK-Rk-r])]", "");
                      }
                      else if (sb.toString() !=null) {
                          cor = sb.toString().replaceAll("[^(§[0-9A-Fa-fK-Rk-r])]", "");
                      }
  
                      if ((sb.toString() !=null) &amp;&amp; !sb.toString().isEmpty()) {
                          JSONObject objeto = new JSONObject();
  
                          objeto.put("text", sb.toString());
                          jmessage.add(objeto);
  
                          sb = new StringBuilder();
                          sb.append(" " + cor);
                      }
  
                      JSONObject objeto = new JSONObject();
                      JSONObject extra = new JSONObject();
  
                      objeto.put("text", cor + args[i]);
  
                      extra.put("action", "open_url");
                      extra.put("value", teste);
  
                      objeto.put("clickEvent", extra);
  
                      jmessage.add(objeto);
                  }
                  else {
                      sb.append(args[i] + " ");
                  }
              }
          }
  </code></pre>
  
  <p>jmessage is a JSONArray create out of the message that is a string input made by a sender (player/console)</p>
  
  <p>The "§[0-9A-Fa-fK-Rk-r]" represents the color of the message, in this methot I am creating the JSONArray where the location of link has the click_event (every time a create a new "text" I need to send it the curret color)</p>