title: Java String matches and replaceAll differ in matching parentheses
body: <p>I have strings with parentheses and also escaped characters. I need to match against these characters and also delete them. In the following code, I use matches() and replaceAll() with the same regex, but the matches() returns false, while the replaceAll() seems to match just fine, because the replaceAll() executes and removes the characters. Can someone explain?</p>
  
  <pre><code>String input = "(aaaa)\\b";
  
  boolean matchResult = input.matches("\\(|\\)|\\\\[a-z]+");
  System.out.printf("matchResult=%s\n", matchResult);
  
  String output = input.replaceAll("\\(|\\)|\\\\[a-z]+", "");
  System.out.printf("INPUT: %s --&gt; OUTPUT: %s\n", input, output);
  </code></pre>
  
  <p>Prints out:</p>
  
  <pre><code>matchResult=false
  INPUT: (aaaa) --&gt; OUTPUT: aaaa
  </code></pre>