whether or not a string contains a character.
I'll probably end up but wiser. Thanks for your assistance.
Jerry
Code: Select all
@echo off & setlocal
Set "string=ABDEFG"
Set "target1=B" & Set "target2=C"
Echo test1
If /I "%string:%target1%=%"=="%target1%" (
Echo %target1% not found in %string%
) Else (
Echo %target1% found in %string%
)
If /I "%string:%target2%=%"=="%target2%" (
Echo %target2% not found in %string%
) Else (
Echo %target2% found in %string%
)
endlocal
setlocal EnableDelayedExpansion
Set "string=ABDEFG"
Set "targ1=B" & Set "targ2=C"
Echo( & Echo test2
If /I "!string:!targ1!=!"=="!targ1!" (
Echo !targ1! not found in !string!
) Else (
Echo !targ1! found in !string!
)
If /I "!string:!targ2!=!"=="!targ2!" (
Echo !targ2! not found in !string!
) Else (
Echo !targ2! found in !string!
)
endlocal & exit /b
result:
test1
B found in ABDEFG
C found in ABDEFG
test2
B found in ABDEFG
C found in ABDEFG