- @set @a=0;/*&echo off & setlocal enabledelayedexpansion
-
- set /p line=<a.txt
- set idx=50
- set /p reirong=请输入要替换的字符串:
- if not defined reirong exit /b
- echo;第一行内容:%line%
- echo;替换字符串为:%reirong%
- echo;替换从第%idx%个字符开始
- for /f "delims=" %%i in ('cscript /nologo /e:jscript %0 "%line%" "%reirong%" "%idx%"') do (
- echo;替换后【%%i】
- )
-
- pause & exit */
-
- var initStr = WScript.Arguments(0);
- var rep = WScript.Arguments(1);
- var idx = parseInt(WScript.Arguments(2));
-
- function replaceStr(initStr, rep, idx) {
- return initStr.substring(0, idx) + rep + initStr.substring(idx + parseInt(rep.length))
- }
- WSH.Echo(replaceStr(initStr, rep, idx));
复制代码
|