【发布时间】:2017-05-25 15:35:24
【问题描述】:
我有这段代码,我在字符串中搜索数组中的单词:
string wordlist = synonymslistbox.Items[q_index].ToString().Split(':')[0].Replace(',', ' ');
var pattern = new Regex(@"\W");
var qa = pattern.Split(first_sentence).Any(w => wordlist.Contains(w));
现在我想实现两件我不知道该怎么做的事情。
- 找出匹配的单词。如果找到,此代码只会返回
true。 - 当 first_sentences 是
i like my banjo时,它不应该在banjo中找到字母a作为单词a。当它出现在这样的句子中时,它应该只将a读作一个单词:i like a big beer at the end of the afternoon。
【问题讨论】: