请问怎样从txt文件中提取想要的数据啊

来源:百度知道 编辑:UC知道 时间:2024/06/15 09:56:24
已知一个txt文件有很多行。如<httpSample t="17277" lt="0" ts="1234764697121" s="false" lb="homepage" rc="Non HTTP response code: java.net.UnknownHostException" rm="Non HTTP response message: www.buaa.edu.cn" tn="线程组 1-1" dt="text" by="1203" />
<httpSample t="14286" lt="0" ts="1234764700116" s="false" lb="homepage" rc="Non HTTP response code: java.net.UnknownHostException" rm="Non HTTP response message: www.buaa.edu.cn" tn="线程组 1-4" dt="text" by="1203" />
<httpSample t="16288" lt="0" ts="1234764698116" s="false" lb="homepage" rc="Non HTTP response code: java.net.Unknow

为什么一定要编程呢?用Replace Pioneer把满足条件的文字提取出来就可以了。

步骤:
1. ctrl-o打开txt文件
2. ctrl-h打开replace窗口
在search for pattern下输入ts="(\d+)"然后把Print Unmatched Unit前面的勾去掉。然后在replace with pattern下输入\1\n
3. 点击Replace即可。

Replace Pioneer下载:
http://www.mind-pioneer.com/replace/Download.html

eof判断的循环
一行行读出来
字符串匹配判断是否跳出
好了