在文本文件&中查找字符串在每个匹配旁边插入数字(按照找到的顺序) [英] Find string in text file & insert numbers beside each match (in the order they were found)

查看:88
本文介绍了在文本文件&中查找字符串在每个匹配旁边插入数字(按照找到的顺序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello

使用VBScript我想在文本文件中找到一个字符串,然后在它旁边插入一个数字。找到了每个匹配顺序的数字。



查找字符串= xyz

第一场比赛插入数字1 = xyz 1

第二场比赛插入号码2 = xyz 2

第3场比赛插入数字3 = xyz 3



我找不到任何类似这样的例子所以希望有人可以帮忙。谢谢。 :)

Hello
With VBScript I would like to find a string inside a text file then insert a number beside it. The numbers being the order each match was found.

Find string = xyz
For 1st match insert number 1 = xyz 1
For 2nd match insert number 2 = xyz 2
For 3rd match insert number 3 = xyz 3

I couldn't find any examples of something like this so hope someone can help. Thank You. :)

推荐答案

为了在文本文件中插入 任何 ,你必须复制文件到那时,添加新数据,然后复制文件的其余部分。



因此读取文件(完全或以块为单位)并找到第一个字符串(如果你在块中执行此操作,请在执行时将块写入到该点)。然后编写新的东西,并继续到文件的末尾。
In order to insert anything in a text file, you have to copy the file up to that point, add the new data, then copy the rest of the file.

So read the file (either completely, or in blocks) and find the first string (if you are doing this in blocks, write the blocks up to that point as you go). Then write the new stuff, and keep going to the end of the file.


这篇关于在文本文件&中查找字符串在每个匹配旁边插入数字(按照找到的顺序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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