要将子字符串替换为另一个字符串,请使用字符串替换功能。
@echo off set str=This message needs changed. echo %str% set str=%str:needs=has% echo %str%
关于上述程序,需要注意的关键是,该示例通过语句%str:needs=has%用字符串" has"替换了" needs"一词。
链接:https://www.learnfk.comhttps://www.learnfk.com/batch-script/batch-script-replace-string.html
来源:LearnFk无涯教程网
上面的命令产生以下输出。
This message needs changed. This message has changed.
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)