Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_words(string)
- words = /\b\w+\b/.match(string)
- words.to_a.each do |word|
- puts word
- end
- end
- test = "A man, a plan, a canal -- Panama"
- count_words(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement