title: java.util.regex.PatternSyntaxException: Unclosed character class near index 0
body: <p>I am trying to replace all square brackets i my string .</p>
  
  <p>This is my program </p>
  
  <pre><code>   package com;
  
  import java.util.ArrayList;
  
  import org.apache.commons.lang3.StringUtils;
  import org.json.JSONException;
  
  public class Teste {
  
      /**
       * @param args
       * @throws JSONException 
       */
      public static void main(String[] args) throws JSONException {
  
  
          String str = "[Fountain#Apple#Big(7)]";
  
          str.replaceAll("[", "").replace("]", "");
  
          System.out.println(str);
  
      }
  
  }
  </code></pre>
  
  <p>But i am getting </p>
  
  <pre><code>Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 0
  [
  ^
      at java.util.regex.Pattern.error(Unknown Source)
      at java.util.regex.Pattern.clazz(Unknown Source)
      at java.util.regex.Pattern.sequence(Unknown Source)
      at java.util.regex.Pattern.expr(Unknown Source)
      at java.util.regex.Pattern.compile(Unknown Source)
      at java.util.regex.Pattern.&lt;init&gt;(Unknown Source)
      at java.util.regex.Pattern.compile(Unknown Source)
      at java.lang.String.replaceAll(Unknown Source)
      at com.Teste.main(Teste.java:19)
  </code></pre>
  
  <p>Could anybody please tell me how to replace all square brackets ??</p>