Batch - replacing with percent symbol

好久不见. 提交于 2020-01-30 05:57:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!