변수가 특정 문자열을 포함하고 있는지에 따라 분기처리를 해야할 경우가 있다. find 나 findstr 의 errorlevel 을 이용해서 처리하면 된다.

set TestStr=imit@imitursa

echo %TestStr% | find "@imitursa" >nul

if errorlevel 1 (echo notfound) else (echo found)


출처 : https://stackoverflow.com/questions/34077831/how-to-see-if-a-string-contains-a-substring-using-batch/34077870#34077870

728x90

+ Recent posts