Batch: How do you search for a variable(text) within another variable(text)?

I want to use a batch file that based on user input, searches for a variable (already set) within the user input.
eg. I figured that this would work:
@echo off
set var=A
set /p var2=Choice: 
(USER TYPES "A B C")
findstr /i /c:"%var%" %var2% OR findstr /i /c:"%var%" ^
if %errorlevel% equ 0 echo.%var% is in %var2%
pause >nul
Exit

You could use something like


@echo off
set var=A
set /p var2=Choice:
echo %var2%|findstr /i "%var%" > file.DOT
if exist file.DOT (echo True) else echo False
pause>nul

HoeraufPrograms (author) 4 years ago
Thank you sir, I realized that I already did this in an subnet mask find using ipconfig, but thanks anyway. This actually helped, but you forgot that instead of: if exist file.DOT (echo True) else echo False, you should have written: if %errorlevel% equ 0 then echo.True and if %errorlevel% equ 1 echo.False