title: java regex quantifiers
body: <p>I have a string like</p>
  
  <pre><code>String string = "number0 foobar number1 foofoo number2 bar bar bar bar number3 foobar";
  </code></pre>
  
  <p>I need a regex to give me the following output:</p>
  
  <pre><code>number0 foobar
  number1 foofoo
  number2 bar bar bar bar
  number3 foobar
  </code></pre>
  
  <p>I have tried</p>
  
  <pre><code>Pattern pattern = Pattern.compile("number\\d+(.*)(number\\d+)?");
  Matcher matcher = pattern.matcher(string);
  while (matcher.find()) {
      System.out.println(matcher.group());
  }
  </code></pre>
  
  <p>but this gives </p>
  
  <pre><code>number0 foobar number1 foofoo number2 bar bar bar bar number3 foobar
  </code></pre>