title: String.replaceAll() throwing IndexOutOfBoundsException
body: <p>I get <code>java.lang.IndexOutOfBoundsException</code>, when I call <code>replaceAll()</code> with replacement text containing <code>$1</code>:</p>
  
  <p>This is from a more complex code, but I simplified it as follows:</p>
  
  <p><a href="http://ideone.com/QCof3">http://ideone.com/QCof3</a></p>
  
  <pre><code>class Test {
      public static void main(String args[]) {
          String test = "@Key";
          String replacement = "$1";
          test = test.replaceAll("@Key", replacement);
          System.out.println(test);
      }
  }
  
  
  Exception in thread "main" java.lang.IndexOutOfBoundsException: No group 1
      at java.util.regex.Matcher.group(Matcher.java:470)
      at java.util.regex.Matcher.appendReplacement(Matcher.java:737)
      at java.util.regex.Matcher.replaceAll(Matcher.java:813)
      at java.lang.String.replaceAll(String.java:2189)
      at Test.main(Main.java:5)
  </code></pre>
  
  <p>Are there any workarounds for this issue? I do not want to use a 3rd party library.</p>