- @set @n=0//& cscript.exe -e:jscript "%~f0"& pause& exit/b
- a = 'a.txt';
- b = 'b.txt';
- fso = new ActiveXObject('Scripting.FileSystemObject');
- ts = fso.OpenTextFile(a);
- txt = fso.OpenTextFile(b).ReadAll();
- s = '';
- while(!ts.AtEndOfStream) {
- ln = ts.ReadLine();
- re = new RegExp('\\b(?:' + ln.replace(/ +/g,'|') + '|\r\n)\\b','g');
- s += txt.match(re).join(' ') + '\r\n';
- }
- s = s.replace(/^ | $/gm,'').replace(/(?:\r\n){2,}/g,'\r\n');
- fso.OpenTextFile('c.txt', 2, true).Write(s);
复制代码
|