title: RegEx, How to get all matches and group? Ruby 1.9.3p125
body: <p>Let's say I have the following string:</p>
  
  <pre><code>google-com, Awesome-net(Ooops), facebook-com / rocket-yet
  </code></pre>
  
  <p>I want to extract all the words ending with <code>-com</code> but have them grouped.</p>
  
  <p>For now, I have tried:</p>
  
  <pre><code>^\w+[-]com
  </code></pre>
  
  <p>That works fine but only catches the first match. How to get all the others? Maybe something using parentheses but I can't figure out how to..</p>
  
  <p>Having all the matched strings into an <code>MatchData</code> object (Ruby) I can work it like an <code>Array</code>.</p>
  
  <p>I'm using ruby 1.9.3p125</p>
  
  <pre><code>1.9.3p125 :124 &gt; original
   =&gt; "google-com, Awesome-net(Ooops), facebook-com / rocket-yet" 
  1.9.3p125 :125 &gt; results = original.match(/(\w+-com)/)
   =&gt; #&lt;MatchData "google-com" 1:"google-com"&gt; 
  </code></pre>