我有这样的绳子
the horse and the hound and the horn that belonged to如何在字符串中的“the”字之后得到所有单词?所以它就这样回来了
the horse, the hound, the horn发布于 2021-04-01 14:35:59
您可以使用String#scan获取每个"the“加一个空格,后面跟着任何单词,然后join这些结果:
"the horse and the hound and the horn that belonged to".scan(/\bthe \w+/).join(", ")
# "the horse, the hound, the horn"https://stackoverflow.com/questions/66906299
复制相似问题