title: How to get possibly overlapping matches in a string
body: <p>I'm looking for a way, either in Ruby or Javascript, that will give me all matches, possibly overlapping, within a string against a regexp.</p>
  
  <hr>
  
  <p>Let's say I have <code>str = "abcadc"</code>, and I want to find occurrences of <code>a</code> followed by any number of characters, followed by <code>c</code>. The result I'm looking for is <code>["abc", "adc", "abcadc"]</code>. Any ideas on how I can accomplish this?</p>
  
  <p><code>str.scan(/a.*c/)</code> will give me <code>["abcadc"]</code>, <code>str.scan(/(?=(a.*c))/).flatten</code> will give me <code>["abcadc", "adc"]</code>.</p>