从txt文件中删除字符串 [英] Remove string from txt file

查看:146
本文介绍了从txt文件中删除字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我想从txt文件中删除字符串.

So basically I want to delete string from txt file.

使用fs

输入示例:

string1
string2
string3
string4

删除string3

删除后就像:

string1
string2
string4

推荐答案

读取文本文件以获取变量中的内容,然后使用

Read the text file get the content in a variable then use String.replace

例如

var stringContent="Here goes the content of the textFile after read"
 var res=stringContent.replace('string3','');
//write back res to the file or do what ever

这篇关于从txt文件中删除字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆