title: Why does Matcher.find() return false when run after Matcher.lookingAt()?
body: <p>I've noticed that calling <code>Matcher.lookingAt()</code> affects <code>Matcher.find()</code>. I ran <code>lookingAt()</code> in my code and it returned <em>true</em>. When I then ran <code>find()</code> so that I can start returning matches, i got <em>false</em>. If I remove the <code>lookingAt()</code> call, <code>find()</code> returns <em>true</em> and prints my matches. Does anyone know why? </p>
  
  <p><strong>Trial1:</strong> </p>
  
  <pre><code>Matcher matches = Pattern.compile("T\\d+").matcher("T234bird");
  System.out.println(matches.lookingAt()); //after running this, find() will return false
  while (matches.find())
      System.out.println(matches.group());
  //Output: true
  </code></pre>
  
  <p><strong>Trial2:</strong> </p>
  
  <pre><code>Matcher matches = Pattern.compile("T\\d+").matcher("T234bird");
  //System.out.println(matches.lookingAt()); //without this, find() will return true
  while (matches.find())
      System.out.println(matches.group());
  //Output: T234
  </code></pre>
  
  <p><strong>Trial3:</strong> </p>
  
  <pre><code>Matcher matches = Pattern.compile("T\\d+").matcher("T234bird");
  while (matches.lookingAt()) 
      System.out.println(matches.group());
  //Output: T234 T234 T234 T234 ... till crash
  //I understand why this happens. It's not my question but I just included it in case someone may try to suggest it
  </code></pre>
  
  <p>Ultimately, what I want to achieve is: First confirm that the match is at the beginning of the string, then print it. I ended up doing: </p>
  
  <pre><code>Matcher matches = Pattern.compile("T\\d+").matcher("T234bird");
  if(matches.lookingAt()) 
      System.out.println(matches.group());
  //Output: T234
  </code></pre>
  
  <p>This solves my problem but my question is: Does anyone know why <code>lookingAt()</code> affect <code>find()</code>?</p>