- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set File = FSO.OpenTextFile("integers.xml", 1, False)
- Set File2 = FSO.OpenTextFile("integers2.xml", 2, True)
- Set RegEx = New RegExp
- RegEx.Pattern = "shortAnimTime|mediumAnimTime|longAnimTime|resumeboost_timeout_param"
- RegEx.IgnoreCase = True
- Set RegEx2 = New RegExp
- RegEx2.Pattern = "[0-9]+"
- RegEx2.IgnoreCase = True
-
- While Not File.AtEndOfStream
- Str = File.ReadLine
- If RegEx.Test(Str) Then
- Set Matches = RegEx2.Execute(Str)
- For Each Match In Matches
- Num = Match / 2
- Next
- Str = RegEx2.Replace(Str, Num)
- End If
- File2.WriteLine Str
- WEnd
复制代码
- var FSO = new ActiveXObject('Scripting.FileSystemObject');
- var File = FSO.OpenTextFile('integers.xml', 1);
- var File2 = FSO.OpenTextFile("integers2.xml", 2, true);
-
- while (!File.AtEndOfStream) {
- str = File.ReadLine();
- if (/shortAnimTime|mediumAnimTime|longAnimTime|resumeboost_timeout_param/.test(str)) {
- str = str.replace(/\d+/, function ($0){return $0 / 2});
- }
- File2.WriteLine(str);
- }
复制代码 练手练手,话说VBS使用正则略复杂 |