从文本文件中读取多行 [英] read multiple line from text file
本文介绍了从文本文件中读取多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设在文本文件中包含以下两行.
20100811_23.15.15.151_Letters_abc.zip xxxx字节
现在时间是10/2/2011 9:30 AM
现在如何从文本文件中读取文件名和dateTime部分?
请帮忙.
谢谢,
Prasant
Hi,
Suppose In a text file it contains following two lines.
20100811_23.15.17.151_Letters_abc.zip xxxx bytes
Time Now is 10/2/2011 9:30 AM
Now How to read that file name and dateTime part from text file ?
Please help.
Thanks,
Prasant
推荐答案
假设您的实际文件更大且更复杂,最好的方法是使用正则表达式.
如果它只是一个简单的2行文件,并且您不熟悉正则表达式,则可以搜索< b>"并使用一些基本的字符串操作来提取中间的文本.
Assuming your actual file is larger and more complex, the best approach would be to use regular expressions.
If it''s just a simple 2 line file and you are not familiar with regular expressions, you could search for "<b>" and use some basic string manipulation to extract the text in between.
希望 ^ ]可能会为您提供帮助.
Hope this[^]might help you.
这篇关于从文本文件中读取多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文