我需要在使用非单词字符的任何地方将查询拆分为单词。例如:
query = "I am a great, boy's and I like! to have: a lot-of-fun and @do$$nice&acti*vities+enjoy good ?times."
应该输出:
["I", "am", "a", "great", "", "boy", "s", "and", "I", "like", "", "to", "have", "", "a", "lot", "of", "fun", "and", "", "do", "", "nice", "acti", "vities", "enjoy", "good", "", "times"]
这可以解决问题,但有更简单的方法吗?
query.split(/[ ,'!:\\@\\$\\&\\*+?.-]/)