Skip to content

Instantly share code, notes, and snippets.

@takahashilabo
Last active December 16, 2015 09:09
Show Gist options
  • Save takahashilabo/5411358 to your computer and use it in GitHub Desktop.
Save takahashilabo/5411358 to your computer and use it in GitHub Desktop.
count the number of words in a string
class String
def count_the_number_of_words_in_a_string(word)
return self.split(/#{word}/).size - 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment