Ruby word count
module StringExtensions def words s = self.dup s.gsub!(/\w+/, 'X') s.gsub!(/\W+/, '') s.length end end
DZone Snippets > sikelianos > words
12366 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
module StringExtensions def words s = self.dup s.gsub!(/\w+/, 'X') s.gsub!(/\W+/, '') s.length end end