When to use Groups in Regular Expressions? : <p>I'm a newbie and learning more about regular expressions. I'm still unclear as to why we use groups. I used them in the below regular expression below:</p>

<pre><code>(http:)\//(\w)+\.(\w)+\.(\w)+
</code></pre>

<p>This will extract URL's, as in the below sentence:</p>

<pre><code>This is http://www.google.com, this is http://www.yahoo.com.
</code></pre>

<p>I did use groups but I was very unsure as to why. I saw this explanation online but confused as to what it means:</p>

<p>By placing part of a regular expression inside round brackets or parentheses, you can group that part of the regular expression together. This allows you to apply a quantifier to the entire group or to restrict alternation to part of the regex.</p>

<p>So any simplified clarification of groups would be great. </p>
