Split variable in 2 after the last dot
Posted: 12 Mar 2018 20:19
I need to cut variables in two smaller variables after the last dot. For example the variable will be and
I use the following code to accomplish this purpose:
The problem is that this code can't manage multiple split variables. For example the variable would totally make this code useless.
would be the output but i need
Don't worry about in var spaces, i can manage them.
I want to split the variable at the last dot but i don't know how to accomplish that. I tried to read the total number of tokens to merge all the tokens up to N-1 but it did not work. Being unable to know the number of dots before the variable is analyzed by the script makes it kinda hard. Any suggestion?
Code: Select all
european.union
Code: Select all
vara=european
Code: Select all
varb=union
Code: Select all
for /f "tokens=1 delims=." %%a in ("%elvariato%") do set vara=%%a
for /f "tokens=2 delims=." %%a in ("%elvariato%") do set varb=%%a
Code: Select all
.
Code: Select all
spain is in.the.european.union
Code: Select all
vara="spain is in"
Code: Select all
varb=the
Code: Select all
vara="spain is in.the.european"
Code: Select all
varb=union
I want to split the variable at the last dot
Code: Select all
.