如何将变量放在变量中 - 批处理

时间:2015-08-12 09:45:31

标签: string variables batch-file replace find

我想知道如何用其他2个变量设置变量。

我的代码:

@echo off

set str=the cat and the mouse and the car and the bull and the joker and the batman and some random guy

echo.%str%
set /p find=
set /p replace=
set str=%str:%find%=%replace%%
echo.%str%
pause

1 个答案:

答案 0 :(得分:0)

尝试delayed expansion

@echo off
setlocal enableDelayedExpansion
set str=the cat and the mouse and the car and the bull and the joker and the batman and some random guy

echo.%str%
set /p find=
set /p replace=
set str=!str:%find%=%replace%!
echo.%str%
pause