bat 判断变量字符串中是否包含字符串

@echo off

rem way 1
set str=machine-order-service
set matchStr=orderd
echo %str% | findstr %matchStr% && echo yes || echo no
rem end way 1
pause

rem way 2
setLocal EnableDelayedExpansion
if not "x!str:%matchStr%=!"=="x%str%" (
    echo Y
) else (
    echo N
)
endlocal
rem end way 2

pause

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。