title: Java scanner won't match square brackets
body: <p>I am having trouble parsing python like lists with scanners in Java. For some reason I seem to be doing something wrong when attempting to detect the square brackets. What puzzles me most is that it seems that somehow the occurences of square brackets in the input triggers the unwanted behaviour.</p>
  
  <pre><code>Scanner scanner1 = new Scanner("a[");
  assert(scanner1.hasNext("a\\[")); // Does not trigger assertion
  
  Scanner scanner2 = new Scanner("[[0]]");
  assert(scanner2.hasNext("\\["));  // Triggers assertion, but why?
  
  Scanner scanner3 = new Scanner(" a[[[0]]");
  assert(scanner3.hasNext("a\\[")); // Triggers assertion, but why?
  </code></pre>
  
  <p>This is using</p>
  
  <pre><code>openjdk version "1.8.0_45"
  OpenJDK Runtime Environment (build 1.8.0_45-b14)
  OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
  </code></pre>