set a=answer1号.txt
set a=%a:answer=%
set a=%a:号.txt=%
echo %a%
Result:
F:\WORK\DOS>set a=answer1号.txt
F:\WORK\DOS>set a=%a:answer=%
F:\WORK\DOS>set a=%a:号.txt=%
F:\WORK\DOS>echo %a%
1作者: toy 时间: 2007-7-7 11:27 标题: 谢谢
谢谢,会用了,不过在windows里关于set的帮助里好象看不到你的这种用法啊作者: Climbing 时间: 2007-7-9 11:39 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.