- @set @n=0;//&cscript -nologo -e:jscript "%~0"<a.txt>b.txt & pause & exit
-
- s = WScript.StdIn.ReadAll();
- a = [[], [], []];
- re = /#1#(.*)#2#(.*)#3#(.*)#4#/g;
- while ((b = re.exec(s)) != null) {
- for (i=1; i<4; i++) {
- if (!/^@+$/.test(b[i])) a[i-1].push(b[i]);
- }
- }
-
- for (i=1; i<4; i++) {
- a[i-1].sort(function(){return Math.random()-0.5});
- }
-
- for (i=1; i<4; i++) {
- j = -1;
- re = new RegExp("(#" + i + "#)[^@]*?(#" + (i+1) + "#)", "g");
- s = s.replace(re,
- function(s0, s1, s2) {
- j += 1;
- return s1 + a[i-1][j] + s2;
- }
- )
- }
- WScript.Echo(s)
复制代码
|