[英]Winforms dot.net Detect if more than x alphabets of string one are present in string two & vice versa
I am working with a C# Windows form application. 我正在使用C#Windows窗体应用程序。 Can anyone help me with the fastest way to detect if more than 'x' number of alphabets of string one are present in string two in same pattern & vice versa. 谁能以最快的方式帮助我,以相同的模式检测第二个字符串中是否存在超过一个字符串的“ x”个字母,反之亦然。
Example: "dog" in "puppydogphotos.jpg" would count as a detection. 示例:“ puppydogphotos.jpg”中的“ dog”将被视为检测到的东西。
I am doing something like below but its failing on some instances: 我正在做下面的事情,但是在某些情况下失败了:
foreach (var word in Kewords.Split(','))
{
var filename = Path.GetFileNameWithoutExtension(e.FullPath).ToLower();
var extenion = Path.GetExtension(e.FullPath).ToLower();
if (word.ToLower().Contains(filename) || word.ToLower().StartsWith(filename) || word.ToLower().EndsWith(filename) || word.Contains(extenion) || filename.ToLower().Contains(word.ToLower()) ||filename.ToLower().StartsWith(word) || filename.ToLower().EndsWith(word))
{
keywordMatch = true;
}
}
Thanks 谢谢
Looks like method 看起来像方法
String.Intersect
should be able to help you. 应该能够帮助您。
Small example here: Implementing an efficent algorithm to find the intersection of two strings 这里的小例子: 实现有效的算法来查找两个字符串的交集
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.