问题
I want to replace "mod" in string with "%":set string=%string:mod=x%
What I should input as "x"?
回答1:
you can do that by enabling delayed expansion so you can use !
as delimiters. Then, doubling the percent sign allows to represent percent as a replacement char.
@echo off
setlocal enabledelayedexpansion
set string=12 mod 15
set string=!string:mod=%%!
echo %string%
result
12 % 15
来源:https://stackoverflow.com/questions/41323488/batch-replacing-with-percent-symbol