In my code, I am looping through each character in a string. I need to test if the character is a space.
This is my code:
if %str% == " " (
::echo Empty
echo | set /p=%space%
goto loopEnd
)
I have also tried:
if [%str%] == [" "] (
::echo Empty
echo | set /p=%space%
goto loopEnd
)
Both give the error
( was unexpected at this time.
Or
] was unexpected at this time.
I don't get errors testing for letters or numbers. What am I doing wrong?
Thanks,
Zach
Try putting quotes around your variable.
if "%str%" == " " (
...
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With