From the documentation for String#count I understand the first example, but I do not understand the rest of the examples:
a = \"hello world\" a.count \"lo\"
Using gsub in string
a = "hello world hello hello hello hello world world world" 2.1.5 :195 > a.gsub('hello').count => 5