Verify a string exists within another string?
Posted: 10 Jan 2012 11:41
If I have a string , containing all of my concatenated args to my batch script, that looks like this:
"-debug -verbose -normi -homedir -repo"
Is there a way to verify that "-verbose" exists within that string without using a space-delimmetted FOR loop to compare each token? Basically, I want a function that works like so IF it is at all possible :
So, in other words, I suppose I am looking for something like FINDSTR.exe that works on a string rather than on a file.
"-debug -verbose -normi -homedir -repo"
Is there a way to verify that "-verbose" exists within that string without using a space-delimmetted FOR loop to compare each token? Basically, I want a function that works like so IF it is at all possible :
Code: Select all
@ECHO off
CALL :MYFUNCTION "-verbose"
IF %ERRORLEVEL%==0 ECHO Success^^!
pause
:MYFUNCTION
[do something here]
EXIT /B %ERRORLEVEL%
So, in other words, I suppose I am looking for something like FINDSTR.exe that works on a string rather than on a file.