I think I have found a solution for you however, the code is not optimized. But, you can optimize it. This code exact result what you ask for. Here is my code =>
static void Main(string[] args)
{
bool exist = false;
var wordListToLookUp = new List<string> { "In the middle", "This is a sample text in the middle", "There is secret in the middle of the forest", "None of your business" };
var lookupWord = "xxx in the middle sample xxx";
List<string> checkerarrary = lookupWord.ToLower().Split(' ').ToList();
foreach (var word in wordListToLookUp)
{
exist = false;
List<string> currentStringarrary = word.ToLower().Split(' ').ToList();
if (checkerarrary.Count >= 3 && currentStringarrary.Count>=3)
{
for(int i=0; i<= checkerarrary.Count-3;i++)
{
for (int c = 0; c <= currentStringarrary.Count - 3; c++)
{
if(checkerarrary[i]== currentStringarrary[c]
&& checkerarrary[i+1] == currentStringarrary[c+1]
&& checkerarrary[i + 2] == currentStringarrary[c+2])
{
exist = true;
}
}
}
}
Console.WriteLine("Found match: {0}", exist);
}
}
Note: I have used the search text at least 3 word .You can adjust it as per you requirements. Please check the code and let me know.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…