I want to match sentence from long text. I already did like below but problem is as you can see in example 1
and example 2
I am using Contains()
method and it match a single letter also a whole sentence.
But I only want to match sentence. So in example 2
the if
statement should fail but currently its returning true and hitting the Console.WriteLine()
.
Any idea how can it be only match exact sentence?
string input = "how to make money. I love you. I want do make something";
string cleaned_input = input.Trim().ToLower().Replace(".", "");
// Example 1
if (cleaned_input.Contains("make something"))
{
Console.WriteLine("Hit this if sentence match not a word or letter match");
}
// Example 2
if (cleaned_input.Contains("m"))
{
Console.WriteLine("Hit this if sentence match not a word or letter match");
}