c#如何使用包含在句子中查找单词

问题描述 投票:0回答:1

对不起我的英语,因为我不是本地人。

我想知道如何使用包含在句子中找到一个单词。但是只有这个词,我会在下面尝试解释...

Thou showedest thy true colors once thou knewest the truth. It seems that, just like me, thou also wert pretending to be someone thou wert not.

 if (Text.Contains("Show")) Console.WriteLine("True");

在这句话中,我想找到“ show”,没有那个词,而是“ showedest”。因此它将返回false,但返回true。我怎么知道单词SHOW和ONLY SHOW是否存在?

c# string contains
1个回答
1
投票

使用空格作为分隔符,如下所示:

if (Text.Contains(" Show ")) Console.WriteLine("True");
© www.soinside.com 2019 - 2024. All rights reserved.