[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[其他] 批处理字符替换是否不能用通配符?

比如:
set str=!str:◎译  名=【中 文 名】!
set str=!str:◎片  名=【原 片 名】!
但是有些时候“◎译  名”是“◎  译  名”。此时想要用通配符,但是set str=!str:◎*片*名=【原 片 名】!完全不起作用,这里*在解释的时候好像是字符而不是通配符,写成set str=!str:◎^*片^*名=【原 片 名】!也不可以。

星号在字符串替换的时候有特殊的意义

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.
Do All in Command Line

TOP

如果不是以*开始呢?比如:
好象按照这个意思来说我可以写成set str=!str:*片  名=【原 片 名】!,但是如果“片  名”之间的空格数不同时,仍然会启作用吗?

TOP

明显不会,不匹配怎么替换

TOP

返回列表