我最近学着用C#正则匹配所要数据,可是如果文件比较大情况下,输出的时候文件内容的前面部分会显示不完整,想请教下大家如何解决这种问题??以下是我的代码,麻烦大家帮忙看下~~using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;namespace rdmbl
{
class mbl
{
static void Main(string[] args)
{
int counter = 0;
string strLine;
string line;
StreamReader file = new StreamReader("C:\\...\\1.txt"); Regex count = new Regex(@"Fuse ID = H\d{7}_\d{3}_-?\d{2}_-?\d{2}");
Regex bin = new Regex(@"Dbin = \d{3,4}"); while ((strLine = file.ReadLine()) != null) {
++counter;
if (count.IsMatch(strLine) || bin.IsMatch(strLine))
{
line = count.Match(strLine).Value + "\t" + bin.Match(strLine).Value + "\n";
Console.WriteLine(line);
} }
file.Close();
Console.ReadLine(); }
}
}
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;namespace rdmbl
{
class mbl
{
static void Main(string[] args)
{
int counter = 0;
string strLine;
string line;
StreamReader file = new StreamReader("C:\\...\\1.txt"); Regex count = new Regex(@"Fuse ID = H\d{7}_\d{3}_-?\d{2}_-?\d{2}");
Regex bin = new Regex(@"Dbin = \d{3,4}"); while ((strLine = file.ReadLine()) != null) {
++counter;
if (count.IsMatch(strLine) || bin.IsMatch(strLine))
{
line = count.Match(strLine).Value + "\t" + bin.Match(strLine).Value + "\n";
Console.WriteLine(line);
} }
file.Close();
Console.ReadLine(); }
}
}
解决方案 »
- 初学 C# 求问 控制台程序为啥运行之后闪一下就消失
- 用c#写了一个简单的地图软件,求提高效率的编码
- DirectX.AudioVideoPlayback 出现试图访问已卸载的AppDomain.
- 求教C#数组的key
- params不定长度参数
- 设置vista防火墙 INetFwPolicy2问题
- <IMG height="100" hspace="1" src='<%# DataBinder.Eval(Container.DataItem,"Image1")%>' width="80" vspace="1">如何字段值为空时此项
- jmail 中关于 body 和 bodytext 的问题
- 按钮备份数据库
- xml中的二进制问题(结帖率100%,行就给分)
- 求 高手帮忙看一下 这是什么问题 急急急!
- 如何截取打印机的数据
看下