I want to split a string by whitespaces, , and ' using a single ruby command.
,
'
word.split will split by white spaces;
word.split
word.split(",") will split by ,;
word.split(",")
word.split("'") will split by '.
word.split("'")
How to do all three at once?
word = "Now is the,time for'all good people" word.split(/[s,']/) => ["Now", "is", "the", "time", "for", "all", "good", "people"]
2.1m questions
2.1m answers
60 comments
57.0k users