我想要一个批处理文件来测试SET命令的子串,比如%var:~5,3%
见下文:
@echo off
Setlocal EnableDelayedExpansion
set var=abcdefghijklmnopqrstuvwxyz
echo.
echo String: abcdefghijklmnopqrstuvwxyz
echo.
echo Samples of Substrings:
echo ~5,3 : %var:~5,3%
echo.~5 : %var:~5%
echo.~0,-2 : %var:~0,-2%
echo.
echo.Test more: (Type 000 for Exit command prompt)
:Loop
Set /P "SubStr=~"
echo.!var:~%SubStr%!
echo.
If %SubStr%==000 Exit
GoTo:Loop
输入用户的输出:~5
fghijklmnopqrstuvwxyz
输入用户的输出:~5,2
var:~5,2
什么是解决方案?
日Thnx。
答案 0 :(得分:1)
:Loop
Set /P "SubStr=~"
If "%SubStr%"=="000" Exit
echo(!var:~%SubStr%!
echo(
GoTo Loop