我如何将变量放入变量中 - 批处理

How do i put variables inside variables - batch

我想知道如何使用其他 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

试试 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