如何批量替换文本里相同内容到不同内容

来源:百度知道 编辑:UC知道 时间:2024/06/22 17:08:25
2个文本A文本内容如下
[1]
user=
word=
name=

[2]
user=
word=
name=

[3]
user=
word=
name=
B文本内容是几千个帐号如:
fhyyfv3d
dfghu75f
t77ghfe4
有什么软件能实现把B文本的帐号批量替换成A文本里的格式
如:[1]
user=fhyyfv3d
word=
name=

[2]
user=dfghu75f
word=
name=

[3]
user=t77ghfe4
word=
name=
以次内推。。小弟现在只能一个一个的去粘贴复制。有办法实现批量转换吗?万分感谢各位大大帮帮小弟吧!

用Replace Pioneer把B文本按行做一个替换就可以了。

详细步骤:
1. ctrl-o打开B.txt
2. ctrl-h打开replace窗口
* 把Replace Unit选成Line
* 在Replace with Pattern输入以下双引号中间的内容,注意不要复制双引号:
"[$line_no]
user=$match
word=
name=

"
3. 点击Replace就可以了。
4. ctrl-s存盘。

试试VBS吧:

strFileB = "e:\temp\B.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileB = objFSO.OpenTextFile(strFileB)
Set objFile = objFSO.CreateTextFile("e:\temp\new.txt")

i = 1
Do While Not objFileB.AtEndOFStream
strLine = objFileB.ReadLine
strLine = "user=" & strLine
objFile.WriteLine "[" & i & "]"
objFile.WriteLine strLine
objFile.WriteLine "word="
objFile.WriteLine "name="
objFile.WriteLine ""
i = i + 1
Loop
objFileB.Close
objFile.Clo