0

How to get the string before the character hyphen? The following code gets the string after the hyphen. How can I reverse this?

set string=1.0.10-SNAPSHOT

echo %string:*-=%

SNAPSHOT

But I want the 1.0.10 instead of SNAPSHOT of if the string is RELEASE

user630702
  • 495
  • 10
  • 32

1 Answers1

1

for extract string before hyphen (special charcter) you need used for

@echo off
set string=1.0.10-SNAPSHOT
echo %string%
for /f "tokens=1 delims=-" %%a in ("%string%") do (
  echo %%a
  )