如何在richtextbox中搜索不同顺序(上下)的单词

本文关键字:顺序 上下 单词 richtextbox 搜索 | 更新日期: 2023-09-27 18:10:14

就像我想从句首或句尾搜索'test'一样,如何使其工作?我应该用什么方法?我将在文本框中键入"test",并在richtextbox中搜索,句子在richtextbox中。谢谢您的宝贵时间。

如何在richtextbox中搜索不同顺序(上下)的单词

您可以使用system . text . regulareexpressions . regex . ismatch()在较大的文本字符串中检查特定的文本字符串:

if (System.Text.RegularExpressions.Regex.IsMatch("text string including test", "test", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
    //test found
}

希望能有所帮助