如何在txt文件中查找特定单词 [英] How to find specific word in txt file
本文介绍了如何在txt文件中查找特定单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨 任何人都可以帮助使用Filestream或任何其他对象在txt文件中查找特定单词的方法.
Hi Can anybody help how to find Specific word in txt file using Filestream or any other object
推荐答案
有很多方法!这是一个:
There are a huge variety of ways! Here is one:
string text = File.ReadAllText(@"D:\Temp\MyLargeTextFile.txt");
MatchCollection matches = Regex.Matches(text, @"\shorrible\s");
foreach (Match match in matches)
{
Console.WriteLine("\"{0}\" at {1}", match.Value, match.Index);
}
这篇关于如何在txt文件中查找特定单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文