3
I need to pick up the last 2 tokens of a variable 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’t use
for /f "tokens=5,6 delims= " %%a in ("%variable%") do set host=%%a & set ip=%%b
echo %ip% %host%
because in this case I am specifying the token 5.6 and what I want to afzer is to get the last 2 tokens dynamically, so I cannot specify any token numbers manually
// this way to only get the last token, considering that the delimiter is space, and there is no way to change the delimiter
FOR %%a in (%variable%) do set lastPart=%%a
ECHO %lastPart%
wanted an explanation in English, I’m still confused https://stackoverflow.com/questions/46943039/get-last-2-tokens-from-a-variable-in-batch/46943397#46943397
– Lucas Vincius Galindo Carvalho
it seems so...
– Lucas Vincius Galindo Carvalho