how to split character in a string

April 22, 2009 at 19:10:30
Specs: Windows XP

I want to write a batch file that can split words within a string. for example, I have a string "Hello-World". I just want to echo out any characters before the "-". so when I echo out, it would just say Hello.

any help would be appreciated.

Thanks in advance

See More: how to split character in a string

Report •

April 22, 2009 at 22:06:50
@echo off & setLocal EnableDelayedExpansion

set str=hello-world

for /f "tokens=1 delims=-" %%a in ("!str!") do (
echo %%a

If at first you don't succeed, you're about average.


Report •
Related Solutions

Ask Question