Best way to count words in a string in Ruby?

Viewed 41385

Is there anything better than string.scan(/(\w|-)+/).size (the - is so, e.g., "one-way street" counts as 2 words instead of 3)?

7 Answers
Related