set /?
环境变量替换已如下增强:
%PATH:str1=str2%
会扩展 PATH 环境变量,用 "str2" 代替扩展结果中的每个 "str1"。
要有效地从扩展结果中删除所有的 "str1","str2" 可以是空的。
str1" 可以以星号打头;在这种情况下,"str1" 会从扩展结果的
开始到 str1 剩余部分第一次出现的地方,都一直保持相配。
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 "str=%str: =%"中,str相当于例子中的path,而:后面的空格相当于str1,而对应str2的是空字符串(也就是什么也没有),所以这个命令就是将str中的所有空格替换为空(也就是去掉)。