1

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

2
  • You want extract 1.0.10? Commented Aug 26, 2021 at 8:41
  • yes that's right
    – user630702
    Commented Aug 26, 2021 at 9:17

1 Answer 1

2

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
  )
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .