删除文本文件中非特定行
我正在寻找一种方法来删除 VB.net 中不符合条件的行。我将在下面举一个我想要做的事情的例子。
基本上,我希望程序遍历一个文本文档(每一行),如果该行不包含某个字符串,它将被删除。
基本上:
hgfhfghhfo TRUE
hdfgdfhdfh MAYBE
tytrteyuet POSSIBLE
ghjfgjgfjf FALSE
这就是文本文档的样子,现在我希望它不要关注“RandomInfo”,而是关注“True/False”,如果它说 TRUE,我希望它也保持不变。如果该行包含除 True 之外的任何内容,我希望将其删除。你们能帮我解决这个问题吗?
I'm looking for a way to delete lines that don't meet a criteria in VB.net. I'll just give a example of what I want done below.
Basically, I want the program to go through a text document (Each line) and if the line doesn't contain a certain string it would get erased.
Basically:
hgfhfghhfo TRUE
hdfgdfhdfh MAYBE
tytrteyuet POSSIBLE
ghjfgjgfjf FALSE
That's what the text document would look like, now I want it to not focus on the "RandomInfo" but on the "True/False" If it says TRUE I want it too keep the line. If the line contains anything except True I want it deleted. Can you guys help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个,
Try this,