如何检查batch file的stringvariables中包含的子string?
例如:
set var1=foobarfoo set regexp=.*bar.* if [check var1 by regexp] echo "YES"
在我的情况下,它只能通过正则expression式检查,只能在.bat文件中检查。
调整答案发现在这里给
@echo off set var1=foobarfoo set "regexp=.*bar.*" echo %var1% echo %regexp% setlocal enableDelayedExpansion echo(%var1%|findstr /r /c:"%regexp%" >nul && ( echo FOUND rem any commands can go here ) || ( echo NOT FOUND rem any commands can go here )