After running the code below, my .bat file closes immediately
@echo off
FOR /F "tokens=*" %%G IN ('dir /b | findstr /r "test.*.apk"') DO set var=%%G
echo %var%
cmd /k
but if i run a slightly modified version without the matching regex it works fine
@echo off
FOR /F "tokens=*" %%G IN ('dir /b /s "test-20190201.apk"') DO set var=%%G
echo %var%
cmd /k
Does anyone know why?