Split string by multiple delimiters

后端 未结 5 1473
迷失自我
迷失自我 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条回答
  •  Happy的楠姐
    2020-12-08 02:28

    word = "Now is the,time for'all good people"
    word.split(/[\s,']/)
     => ["Now", "is", "the", "time", "for", "all", "good", "people"] 
    

提交回复
热议问题