Split string by multiple delimiters

后端 未结 5 1468
迷失自我
迷失自我 2020-12-08 01:52

I want to split a string by whitespaces, , and \' using a single ruby command.

  1. word.split will split by white spaces

5条回答
  •  离开以前
    2020-12-08 02:31

    Here is another one :

    word = "Now is the,time for'all good people"
    word.scan(/\w+/)
    # => ["Now", "is", "the", "time", "for", "all", "good", "people"]
    

提交回复
热议问题