批处理脚本 - 删除



字符串替换功能也可用于从另一个字符串中删除子字符串。

示例

@echo off 
set str = Batch scripts is easy. It is really easy. 
echo %str% 

set str = %str:is = % 
echo %str%

上述程序中值得注意的关键内容是,使用 :’stringtoberemoved’ = 命令,从字符串中删除了单词“is”。

输出

上述命令会产生以下输出。

Batch scripts is easy. It is really easy. 
Batch scripts easy. It really easy.
batch_script_strings.htm
广告
© . All rights reserved.