Skip to content

Instantly share code, notes, and snippets.

@Nameo0
Created December 10, 2014 04:58
Show Gist options
  • Save Nameo0/54cbd8c22e418e09d9eb to your computer and use it in GitHub Desktop.
Save Nameo0/54cbd8c22e418e09d9eb to your computer and use it in GitHub Desktop.
a = "This is a thing that is this"
puts a.count "is"
# This returns 9 and I need it to return 4 (the amount of times 'is' appears).
@havenwood
Copy link

"This is a thing that is this".scan('is').size
#=> 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment