From: "Jan E." Date: 2012-07-06T17:06:07+09:00 Subject: Re: Management of words in a string Hi, Joao Silva wrote in post #1067618: > As I can implement the above? For large text you may use String#scan, which has the advantage of not collecting all words in an array like String#split does: input_text = 'This is a sentence.' word_count = input_text.strip.scan(/\s+/).size + 1 But like Jesus already said, this simple approach will not always work. If the "words" in your text may contain whitespace, then looking for whitespace will obviously fail. You'll have to use a dictionary in this case. This would also cover errors (missing or superfluous whitespace). -- Posted via http://www.ruby-forum.com/.