- @echo off
- echo "you are my super star!">test.txt
- echo "you are :my super star!">>test.txt
- echo "you are my super star!">>test.txt
- echo.
- @echo off
- ::去引号
- setlocal EnableDelayedExpansion
- for /f "tokens=* delims=" %%i in (test.txt) do (
- set var=%%i
- set var=!var:"=!
- echo !var!>>ls.txt
-
- )
- pause
- echo.
- @echo off
- ::去冒号
- setlocal EnableDelayedExpansion
- for /f "tokens=* delims=" %%i in (ls.txt) do (
- set var=%%i
- set var=!var::=!
- echo !var!>>ls1.txt
-
- )
- pause
- echo.
- ::把my替换为my (not you)
- @echo off
- setlocal EnableDelayedExpansion
- for /f "tokens=* delims=" %%i in (ls1.txt) do (
- set var=%%i
- set var=!var:my=my ^(not you^)!
- echo !var!
-
- )
- echo.
- pause
复制代码 把set var=!var:my=my (not you)!
改成这样试试
set var=!var:my=my ^(not you^)! |