 <p>Imagine you have the following text:</p> <pre><code>BAAAAAAAAD </code></pre> <p>The following regexs will return:</p> <pre><code>/B(A+)/ =&gt; 'BAAAAAAAA' /B(A+?)/ =&gt; 'BA' /B(A*)/ =&gt; 'BAAAAAAAA' /B(A*?)/ =&gt; 'B' </code></pre> <p>The addition of the "?" to the + and * operators make them "lazy" - i.e. they will match the absolute minimum required for the expression to be true. Whereas by default the * and + operators are "greedy" and try and match AS MUCH AS POSSIBLE for the expression to be true.</p> <p>Remember + means "one or more" so the minimum will be "one if possible, more if absolutely necessary" whereas the maximum will be "all if possible, one if absolutely necessary".</p> <p>And * means "zero or more" so the minimum will be "nothing if possible, more if absolutely necessary" whereas the maximum will be "all if possible, zero if absolutely necessary".</p>