title: Using capturing groups with reluctant, greedy, and possessive quantifiers
body: <p>I was practicing regular expressions of java in the tutorial of Oracle. In order to understand greedy, reluctant, and possessive quantifiers better, I created some examples. My question is how those quantifiers work while capturing groups. I didn't understand using quantifiers in that manner, for example, reluctant quantifier looks as if it doesn't work at all. Also, I searched a lot in the Internet and only saw expressions like (<code>.*?</code>). Is there a reason why people usually use quantifiers with that syntax, not something like <code>&quot;(.foo)??&quot;</code>?</p>
  <p>Here is the reluctant example:</p>
  <pre><code>Enter your regex: (.foo)??
  Enter input string to search: xfooxxxxxxfoo
  I found the text &quot;&quot; starting at index 0 and ending at index 0.
  I found the text &quot;&quot; starting at index 1 and ending at index 1.
  I found the text &quot;&quot; starting at index 2 and ending at index 2.
  I found the text &quot;&quot; starting at index 3 and ending at index 3.
  I found the text &quot;&quot; starting at index 4 and ending at index 4.
  I found the text &quot;&quot; starting at index 5 and ending at index 5.
  I found the text &quot;&quot; starting at index 6 and ending at index 6.
  I found the text &quot;&quot; starting at index 7 and ending at index 7.
  I found the text &quot;&quot; starting at index 8 and ending at index 8.
  I found the text &quot;&quot; starting at index 9 and ending at index 9.
  I found the text &quot;&quot; starting at index 10 and ending at index 10.
  I found the text &quot;&quot; starting at index 11 and ending at index 11.
  I found the text &quot;&quot; starting at index 12 and ending at index 12.
  I found the text &quot;&quot; starting at index 13 and ending at index 13.
  </code></pre>
  <p>For reluctant, shouldn't it show &quot;xfoo&quot; for index 0 and 4 ? And here is the possessive one:</p>
  <pre><code>Enter your regex: (.foo)?+ 
  Enter input string to search: afooxxxxxxfoo
  I found the text &quot;afoo&quot; starting at index 0 and ending at index 4
  I found the text &quot;&quot; starting at index 4 and ending at index 4.
  I found the text &quot;&quot; starting at index 5 and ending at index 5.
  I found the text &quot;&quot; starting at index 6 and ending at index 6.
  I found the text &quot;&quot; starting at index 7 and ending at index 7.
  I found the text &quot;&quot; starting at index 8 and ending at index 8.
  I found the text &quot;xfoo&quot; starting at index 9 and ending at index 13.
  I found the text &quot;&quot; starting at index 13 and ending at index 13.
  </code></pre>
  <p>And for possessive, shouldn't it try the input only for one time? I'm really confused especially by this one because of trying every possibility.</p>
  <p>Thanks in advance!</p>