bat文件如何逐行读取文件内容并匹配输出新文件
例:有一个txt内容如下:
if DzAPI_Map_HasMallItem(Player(0),"ZABC")==true then
DzAPI_Map_HasMallItem(Player(0),"WEIY")
输出:
ZABC
WEIY
本来想用正则匹配DzAPI_Map_HasMallItem关键字后面第一个引号后四位,没写出来
bat文件如何逐行读取文件内容并匹配输出新文件
例:有一个txt内容如下:
if DzAPI_Map_HasMallItem(Player(0),"ZABC")==true then
DzAPI_Map_HasMallItem(Player(0),"WEIY")
输出:
ZABC
WEIY
本来想用正则匹配DzAPI_Map_HasMallItem关键字后面第一个引号后四位,没写出来
D:\test\a.txt:
if DzAPI_Map_HasMallItem(Player(0),"ZABC")==true then
DzAPI_Map_HasMallItem(Player(0),"WEIY")
d:\test\t.vbs:
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = """(.*)""" ' 设置模式。
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("a.txt")
Do While Not f.AtEndOfStream
ln= f.ReadLine
Set Matches = regEx.Execute(ln) ' 执行搜索。
RetStr=""
Gap=""
For Each Match in Matches ' 遍历匹配集合。
RetStr = RetStr & Match.SubMatches(0) & Gap
Gap=" "
Next
WScript.Echo RetStr
Loop
f.Close
d:\test\t.bat:
cscript /nologo t.vbs
cd /d d:\test
t.bat
输出
ZABC
WEIY