Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
就像我想从句子的开头或结尾搜索“测试”,如何使它工作?我应该使用什么方法?我将在文本框中输入“test”,然后在richtextbox 中搜索,句子在richtextbox 中。感谢您抽出宝贵的时间。
您可以使用 System.Text.RegularExpressions.Regex.IsMatch() 检查较大文本字符串中的某些文本字符串:
if (System.Text.RegularExpressions.Regex.IsMatch("text string including test", "test", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { //test found }
希望这可以帮助