title: Ruby: How to count the number of times a string appears in another string?
body: <p>I'm trying to count the number of times a string appears in another string.</p>
  
  <p>I know you can count the number of times a letter appears in a string:</p>
  
  <pre><code>string = "aabbccddbb"
  string.count('a')
  =&gt; 2
  </code></pre>
  
  <p>But if I search for how many times 'aa' appears in this string, I also get two.</p>
  
  <pre><code>string.count('aa')
  =&gt; 2
  </code></pre>
  
  <p>I don't understand this. I put the value in quotation marks, so I'm searching for the number of times the exact string appears, not just the letters.</p>