@echo off
rem 替换字符串
set a=www.baidu.com
set a=%a:.=-%
echo %a%
rem 截取字符串
set a=www.baidu.com
set a=%a:~4,4%
set a=www.baidu.com
set a=%a:~-5%
echo %a%
set a=www.baidu.com
set a=%a:~0,-5%
echo %a%
pause
exit
转载于:https://www.cnblogs.com/lvchenfeng/p/5154842.html