我有一个批处理文件可以帮助我进行字符串操作。它作为插件/功能。问题是,我不知道如何在字符串操作中使用变量。
以下是我遇到问题的代码:
set result=%_unstring:%_charstoreplace%=%_replacementchars%
变量_unstring
,_charstoreplace
和_replacementchars
都是参数。
如何在操纵%_unstring%
时使用变量?
答案 0 :(得分:1)
SET "unstring=some string containing stuff"
SET "charstoreplace=ing cont"
SET "replacementchars=with this"
CALL SET "result=%%unstring:%charstoreplace%=%replacementchars%%%"
SET result
可能是最简单的。它依赖于批处理使用的解析方法。