Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby Word Count

DZone's Guide to

Ruby Word Count

·
Free Resource

module StringExtensions
  def words
    s = self.dup
    s.gsub!(/\w+/, 'X')
    s.gsub!(/\W+/, '')
    s.length
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}