我来一个if的- @echo off
- set "str= abc d "
- for /f "tokens=* delims= " %%a in ("%str%") do (
- set "var=%%a"
- call :ie
- )
- echo.
- echo 去除空格前: [%str%]
- echo.
- echo 去除空格后: [%var%]
- echo.
- pause&goto :eof
-
-
- :ie
- if "%var:~-1%"==" " (set "var=%var:~0,-1%"&goto ie) else goto :eof
复制代码
|