title: Java regular expression with lookahead
body: <p>is there a way to print out lookahead portion of a regex pattern in java?</p>
  
  <pre><code>    String test = "hello world this is example";
      Pattern p = Pattern.compile("\\w+\\s(?=\\w+)");
      Matcher m = p.matcher(test);
      while(m.find())
          System.out.println(m.group());
  </code></pre>
  
  <p>this snippet prints out :</p>
  
  <blockquote>
    <p>hello<br> world<br> this<br> is<br></p>
  </blockquote>
  
  <p>what I want to do is  printing the words as pairs :</p>
  
  <blockquote>
    <p>hello world<br> world  this<br> this
    is<br> is example<br></p>
  </blockquote>
  
  <p>how can I  do that?</p>