title: My Java regex isn't capturing the group
body: <p>I'm trying to match the username with a regex. Please don't suggest a split.</p>
  
  <pre><code>USERNAME=geo
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>    String input = "USERNAME=geo";
      Pattern pat = Pattern.compile("USERNAME=(\\w+)");
      Matcher mat = pat.matcher(input);
      if(mat.find()) {
          System.out.println(mat.group());
      }
  </code></pre>
  
  <p>why doesn't it find <code>geo</code> in the group? I noticed that if I use the <code>.group(1)</code>, it finds the username. However the <code>group</code> method contains <code>USERNAME=geo</code>. Why?</p>