我想匹配两个字符串之间的常用词
// C# code
string str1,str2;
我想检查字符串str1的前十五个单词中的五个单词
str1="Musician Ben Sollee on the Ravages of Coal and the Wonders of the Bicycle"
str2="There is Wonders of Musician Ben Sollee on the Ravages of Coal"
我想跳过“of”、“on”、“the”等以上字符串的动词比较。只检查没有动词的单词...
从上面的字符串我想比较 str2 和 str1 如果它包含五个重复的单词然后给出消息它包含一些重复的单词..
我如何比较它并检查它是否包含重复项。我对 jQuery 或 C# 答案很满意。
最佳答案
奖励积分的单行 Linq 查询?
string[] str1Words = ...
string[] str2Words = ...
string[] dontCheck = {"of", "a", "the"};
var greaterThanFive = str1Words.Join(str2Words, s1 => s1, s2 => s2, (r1, r2) => r1)
.Distinct()
.Where(s => !dontCheck.Contains(s))
.Count() > 5;
关于c# - 如何使用 C# 或 jquery 匹配段落中的重复单词?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6420669/