Just like /\w+/, but doesn't consider underscore part of a word.
class String def word_count frequencies = Hash.new(0) downcase.scan(/[0-9A-Za-z]/) { |word, ignore| frequencies[word] += 1 } return frequencies end end %{"this is a test."}.word_count