I need to get the last 2 tokens of a variable in batch
the variable is
Rastreando a rota para user722-PC [192.168.1.106]
The output I need is a variable containing
user722-PC
and another containing
[192.168.1.106]
and no, I can not use
for /f "tokens=5,6 delims= " %%a in ("%variable%") do set host=%%a & set ip=%%b
echo %ip% %host%
In this case I am specifying token 5.6 and what I want to do is to get the last 2 tokens dynamically, so I can not specify any token numbers manually
FOR %%a in (%variable%) do set lastPart=%%a
ECHO %lastPart%