Reputation: 3185
I have a string stored in variable %var% which looks like:
something.contains.text
- a basic string delimited by "."
I need to end up with just "Something" in a new variable.
So far I can only seem to get contains.text
or just contains
, but cannot get something
Upvotes: 3
Views: 2821
Reputation: 70923
While I would solve it with the code in npocmaka's answer, here's a one-liner for basic strings:
set var=something.contains.text
set new_var=%var:.=&rem %
The way it works is that it replaces the dots with a command concatenation character (&
) and starts a comment (rem
)
Upvotes: 4
Reputation: 57252
for /f "tokens=1 delims=." %%a in ("%var%") do set "new_var=%%a"
Upvotes: 1