Advertisement
Guest User

Untitled

a guest
Feb 29th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.17 KB | None | 0 0
  1. def count_words(string)
  2.   words = /\b\w+\b/.match(string)
  3.   words.to_a.each do |word|
  4.     puts word
  5.   end
  6. end
  7.  
  8. test = "A man, a plan, a canal -- Panama"
  9.  
  10. count_words(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement