【发布时间】:2019-08-09 21:24:28
【问题描述】:
有谁知道我如何在字符串中搜索特定字符并提取它们所在的实际单词?如果一个单词确实包含特定字符,我如何根据该单词拆分字符串?这是我正在尝试做的一个例子。输入语句(字符串)为:"We both arrived at the garage this morning"。然后我想在该字符串中搜索所有出现的字符"ar"。如果任何单词包含这两个字母,我想根据这些单词拆分字符串。所以在这个例子中,分割字符串看起来像:
Element 1: "We both"
Element 2: "arrived"
Element 3: "at the"
Element 4: "garage"
Element 5: "this morning"```
【问题讨论】: