Case sensitive comparison-why doesn't this work?
Posted: 10 Sep 2020 22:06
I can't see why the code below does not give the results I expect,
give one match in a case sensitive comparison. The code represents
an issue in a larger script. I'm probably confused and need expert help
Yes, I read /? IF
Jerry
give one match in a case sensitive comparison. The code represents
an issue in a larger script. I'm probably confused and need expert help
Yes, I read /? IF
Jerry
Code: Select all
@echo Off
setlocal EnableDelayedExpansion
set "string=a"
call :myfun string
set "string=A"
call :myfun string
endlocal & exit /b
:myfun
setlocal EnableDelayedExpansion
set "instring=!%~1!"
If "%instring:a=%"=="%instring%" (echo a not found in %instring%) Else echo found a in %instring%
If "%instring:A=%"=="%instring%" (echo A not found in %instring% ) Else echo found A in %instring%
endlocal & exit /b
found a in a
found A in a
found a in A
found A in A