title: Regex - How to discard match
body: <p>How can I get a regular expression to discard a part of the match?</p>
  
  <pre><code>public class main {
      public static void main(String[] args) {
          Pattern pattern = Pattern.compile("(?&lt;=b)([xyz])(?:a*?)c");
          String string = "abyaacbxaaac";
          Matcher matcher = pattern.matcher(string);
          while(matcher.find()){
              System.out.println(matcher.group());
          }
      }
  }
  </code></pre>
  
  <p>The output here is:   </p>
  
  <pre><code>yaac   
  xaaac
  </code></pre>
  
  <p>I'd like it to output only <code>y</code> and <code>x</code> when I run <code>System.out.println(matcher.group());</code><br>
  I.e. Discarding what is matched by<code>(?:a*?)</code> </p>
  
  <p>P.S.</p>
  
  <p>I know I can use <code>matcher.group(1)</code> to get <code>x</code> and <code>y</code> on its own but I'd like the entire match to output <code>x</code> and <code>y</code> only without having to access specific groups.</p>