从 %var% 添加和删除文本 - 批处理 - 简单
Adding and Removing text from %var% - Batch - Simple
我想知道是否有人可以简单地向我解释如何从变量中批量添加和删除特定 keywords/text...
您可以使用文本替换:set var=%var:foo=%
从 %var%
中删除 foo
。
Environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
would expand the PATH environment variable, substituting each
occurrence of "str1" in the expanded result with "str2". "str2" can
be the empty string to effectively delete all occurrences of "str1"
from the expanded output. "str1" can begin with an asterisk, in which
case it will match everything from the beginning of the expanded
output to the first occurrence of the remaining portion of str1.
要向环境变量添加内容,您可以在开头或结尾添加它:
set "var=beginning %var%"
set "var=%var% end"
如果你需要中间的东西,也可以使用子字符串:
set "var=%var:~0,5% middle %var:~5%"
我想知道是否有人可以简单地向我解释如何从变量中批量添加和删除特定 keywords/text...
您可以使用文本替换:set var=%var:foo=%
从 %var%
中删除 foo
。
Environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded output. "str1" can begin with an asterisk, in which case it will match everything from the beginning of the expanded output to the first occurrence of the remaining portion of str1.
要向环境变量添加内容,您可以在开头或结尾添加它:
set "var=beginning %var%"
set "var=%var% end"
如果你需要中间的东西,也可以使用子字符串:
set "var=%var:~0,5% middle %var:~5%"